Creating a login page for your WordPress password protected categories
If you're using the WordPress Password Protected Categories plugin, then you'll need a way for people to log into your protected categories. This will depend on the type of protection you're using for your categories:
- Password protected categories can be unlocked simply by entering a correct password for the category - you don't need to be logged into an actual WordPress user account. The plugin comes with its own login form for password protected categories.
- User or role protected categories unlock automatically when a user logs into their account on your website. This uses the standard WordPress login system, so the plugin doesn't include a login form for this type of category.
Below, we will explain how to create login forms for both types of protected category.
1. Password protected categories login page
There are two ways for visitors to log into password protected categories:
- When they visit a password protected category (i.e. the category archive) or visit one of the posts inside the category, or one of its sub-categories. The visitor will be shown a simple login form where they can enter a password. They must enter the correct password for the category to unlock it and reveal the contents.
- From a central login page. The central login page allows the visitor to login to any password protected category in your WordPress site. A login form is displayed on this page where the user can enter a password.
If the user enters a correct password for a category, they will automatically be redirected to that category. The login form will direct them to the first matching category that it finds, so it makes sense to use a different password for each category to avoid any potential conflicts.
Create a central password login page
To create a central login page for your password protected categories, you should select a page from the Central login page option in the plugin settings. You can then link to this page from wherever you want on your site (e.g. adding it to the navigation menu).
The plugin also provides a shortcode that you can use to add login forms anywhere on your site. To do this, simply add
[category_login] where you want.
Please note that when someone clicks on a link to a category directly, they will see a simple login form and not the central login page. The central login page is only used when people click on a link to that page.
Password login form shortcode options
By default, the message you have entered on the plugin settings page will appear above the password protected categories login form.
You can override this for each individual login form using the following shortcode options:
heading="Your heading here"- overrides the heading above the password login form.
show_heading="false"- hides the heading above the password login form. This shortcode option is set to "true" by default, so you only need to use it if you want to hide the heading.
message="your message here"- overrides the message displayed above the password entry field.
label=""- overrides the 'Label' text which appears in or next to the password entry field (depending on your theme).
button_text=""- overrides the button text on the category login form.
[category_login heading="Login Below" show_heading="false" message="Please enter your password below:" label="Enter password" button_text="LOGIN"]
2. User and role protected categorie
As we saw above, the other type of protect category involves restricting it to specific logged in users or user roles. With this type of protection, the categorywill automatically be unlocked whenever a user logs into their account on your website. This means that you don't need a special login form for your protected categories - you just need a normal user login form.
This is not part of our plugin, as the login system is part of WordPress itself. Here is some advice on different ways you can allow users to log into their accounts:
- The default WordPress login page at [your-domain.com]/wp-login.php.
- Logged out users are shown a login form when they try to access the WooCommerce Account page.
- You can create a professional-looking front end user account login form with a plugin such as Theme My Login or Profile Builder.
Whichever method you use for people to log into their accounts, they can access their user and role protected categories after logging in.
Once people have logged in, you will need to consider the best way for them to navigate to their protected categories.
Can people automatically log into a protected category by clicking a link/URL?
Again, this depends on the type of protection you are using for your categories:
- Password protected categories - This is not possible because the user must enter a correct password to unlock the category, and there is no way to bypass this.
- User or role protected categories - You can do this by using our plugin with a WordPress auto-login plugin such as Autologin Links.
Can I create a registration page for my protected categories?
Yes, please see our article on how to let people register to access protected categories.
Can I add a popup login form?
You can use Password Protected Categories with several free WordPress popup plugins:
- If you are using password protected categories then we have tested the
[store_login]shortcodes with the following popup marker plugins.
- If you are using the user or role protection options, then you can create a login form using a plugin such as Theme My Login or Profile Builder. This comes with a shortcode that you can use to create a user registration or login form. Install any popup maker plugin, and add the login shortcode to the popup window.
Whichever popup plugin you use, we recommend setting it up to only display the popup outside of your protected category pages and their posts. That way, people will never be shown the login form after unlocking a protected category.
Please note that while you can add a login form to these third-party popup plugins, it's not possible to automatically open a popup when someone clicks on a direct link to a protected category or post. Instead, they will be shown a page containing the password login form (for password protected categories); or the page selected in the 'When logged out' setting (for user or role protected categories).
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. You can add it to regular WordPress pages .
Once a customer enters their username and password, they can be redirected to either the store or to a specific unlocked category page.
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 a 'Popup showing limitation' option which controls how many times the popup will appear to each person. It’s best not to tick this box to avoid any conflicts with the Password Expiry setting in Password Protected Categories.
Hustle Marketing, Social Share, Email Opt-in Form and Popup Plugin
Hustle works with Password Protected Categories in the same way as the other popup plugins listed above.