How to create protected WooCommerce categories
The WooCommerce Protected Categories plugin provides a range of ways to protect your product categories. This article will explain how to create password protected categories; and how to restrict categories so that only specific roles or individual users can access them.
Password protected, user and role protected categories
Follow these steps to protect a WooCommerce category. You can protect as many categories as you like, while leaving others public:
- Go to Products → Product Categories.
- Click the option to either add a new category or edit an existing one.
- In the ‘Visibility’ section above the ‘Add New Product Category’ button, select ‘Protected’.
- Tick one or more of the following category protection options:
- Password protected - Password protect the category by adding one or more passwords. To add more passwords for a category, click the plus (+) icon next to the password box and add a new row for each additional password. Click the minus (-) icon to delete a password. Customers can unlock the category by entering any correct password.
- User roles - Click in the box and select one or more user roles who will have access to the protected category.
- Users - Click in the box and select one or more specific users who will have access to the protected category. (Tip: If you have lots of users, start typing a username in the box to search for a specific user.)
- For more information about how protected categories work together and the logic rules in the plugin, please see this article.
- To learn how to redirect users to their protected category page after they login, please see this article.
The plugin also has an option to mark categories as 'Private'. This automatically shows the category and its contents to logged in users with certain user roles, while hiding it from everyone else.
Private categories work in exactly the same way as private WordPress pages or posts, which you can read about in the WordPress Codex. They are normally restricted to Administrators and Store Managers.
For most people, we recommend using the 'User roles' option rather than 'Private'. This is because the 'User roles' option gives you more control over which user levels can access the category. Please see our separate article if you do wish to create private categories.
How to protect sub-categories
You can create more complex navigation structures by protecting a category and adding ‘child’ categories to it. To add sub-categories, create a new category in Products → Product Categories and select your protected category as the ‘Parent’. You can also create deeper navigation levels by creating sub-sub-categories, sub-sub-sub categories, and so on.
All sub-categories should be set to 'Public'. The protection for the main ‘parent’ category will automatically apply to all its child categories so you don’t need to protect each one individually.
For example, let's say that you password protected a category and added various child and grandchild categories. When someone tries to view the main parent category, a child category, a grandchild category or any of the products within these categories, they will be promoted for the same password. Once they have entered the password, they will automatically have access to all these WooCommerce categories and their products.
How to protect a whole WooCommerce store
If you want to protect your entire WooCommerce store then you can do this with WooCommerce Protected Categories.
- Create a main category for your store in Products → Product Categories and protect it. You can then structure your store by adding sub-categories and products. You don’t need to protect any of the individual sub-categories or their products as they will automatically inherit the same protection as the main category.
- Go to WooCommerce → Settings → Products → Protected Categories and untick the boxes that show the protected categories and products in the public-facing store and menus.
For added security, you can use WooCommerce Protected Categories with our dedicated plugin WooCommerce Private Store. This has extra features such as hiding links to the cart and checkout, and blocking all your WooCommerce content from search engines and sitemaps.
You can use WooCommerce Private Store to make your entire store private on a global basis. You can then use WooCommerce Protected Categories to show different categories to different people, as required. The two plugins are designed to work perfectly together.
Can I add a product to more than one category?
Each product can only be in one protected category, otherwise it creates a conflict between the different protection methods. Similarly, you can't have the same product in a public AND a protected category, as it will automatically be protected if you do this.
We recommend that you structure your store with this in mind. For example:
- If you want to sell the same protected to different user groups, then you will need to duplicate them and put one in each category. (The Duplicate Post plugin makes it easy to duplicate WooCommerce products. If you want to manage inventory across each version of the product then we recommend the Group Stock Manager plugin. This lets you share stock levels across multiple products.)
- If you need to add the same product to multiple categories that are available to the same users, then it's ok to add it to more than one category. Just make sure you protect each category in the same way. For example, if you're adding the product to more than one password protected category, then you will need to add the same password for each category. If you're using role or user protection, then each category will need to be restricted to the same roles or users. This will prevent any conflicts.
Will my protected categories be hidden from search engines?
Please note that WooCommerce Protected Categories does not affect how search engines view your categories or products.
There are some steps you can take to hide your protected WooCommerce content from search engines:
- Use an SEO plugin such as Yoast SEO to mark the categories and products as ‘noindex’. This will prevent them from being indexed at all.
- If your Catalogue Visibility settings are set to hide your protected categories and products from the public areas of your store, then search engines are unlikely to crawl them because this only happens if a search engine can find them. However, there may still be links to your protected categories and products elsewhere, such as your XML sitemap, so it’s worth noindexing them if you are concerned about this.
If you want to hide your entire store then the safest option is to use the WooCommerce Private Store plugin instead.