Private store login shortcode
WooCommerce Private Store comes with a simple shortcode that you can use to add a password entry form to your site. You can use this shortcode in any location, including in sidebar widgets, Gutenberg blocks, and a text/code block in any page builder plugin.
Note: The login form described in this article is for the password protection that comes with WooCommerce Private Store. If you want to unlock the store whenever someone logs into their user account, then checkout our article on the ‘Logged In Users’ option instead.
How to add a WooCommerce store login form
You can add a login form anywhere on your site by adding the shortcode:
[store_login]. If you’re using the Gutenberg editor then you can add this to a ‘Shortcode’ or ‘Paragraph’ block.
By default, this will create a login form with the text that you added on the plugin settings page. If you’re planning to add different login forms to different parts of your site, then you can also configure the text for the individual form within the shortcode. For example:
[store_login message="Welcome to my store. Enter the password to login."]
There are 3 shortcode options:
message– The message to display above the login form prior to login.
unlocked_message– The message to display after the store is unlocked. When the store is unlocked, this message is displayed instead of the login form. For example, if you use the shortcode in a sidebar, the sidebar widget will probably be visible after login, so you might want to show a message here. You can set this to
falseto hide the message – e.g.
visit_store– When the store is unlocked, a link is displayed to take the user to the main shop page. The default text is “Visit Store” but you can customise this by setting this shortcode option. E.g.
[store_login visit_store="Enter Shop"]. You can also set this to
falseto hide this link. By default, this link will take the customer to the main shop page. However, if you have set a custom redirect URL in the plugin settings, they will be taken to this page instead.
[store_login message="Welcome to our store. Enter the password to login." unlocked_message="Welcome to the members-only store." visit_store="Visit Shop"]
Can I create a popup login form?
We have tested the
[store_login] shortcode with the following WordPress popup plugins, which we have described below. Use WooCommerce Private Store with either of these plugins to add a popup login form where customers can enter the password to unlock your private store.
We recommend setting up the popup to only appear on non-WooCommerce pages. This prevents it from popping up again after your customers have unlocked the private store and started shopping.
Popup Maker by Code Atlantic
Code Atlantic’s free Popup Maker plugin allows you to choose which pages to add a popup login form to.
Popup Builder by Sygnoos
The free Popup Builder plugin by Sygnoos works with the password login form in exactly the same way as the Code Atlantic plugin.
It also comes with “Popup showing limitation” option which controls how many times the popup will appear to a user. It’s best not to tick this box to avoid any conflicts with the ‘Password Expires After‘ setting in WooCommerce Private Store.
Can customers log out of the private store?
Please see our separate article about logging out of the WooCommerce private store.