Do you need to show some of your products only to certain customers? Maybe you have a wholesale store and don’t want some customers to see the products/prices you’re offering to other customers. Or perhaps you’re a photographer and you only want customers to see their own photographs
Whilst a Google search will show up a lot of results containing snippets that help you to hide categories, for the non-coding store owner, hiding one or more categories, devising a system to allow customers to only see certain categories and then giving customers a way of viewing hidden categories may seem daunting.
Barn2 Media’s WooCommerce Hide Categories Plugin seeks to make the tasks of hiding and showing categories in your store easy, so let’s take a look at what it does.
The Tldr Summary/Verdict
It is possible to hide categories from specific users/roles using PHP snippets but it would take a lot of code to allow the backend user to choose which categories they want to hide, give them a choice of how the categories are hidden and provide a user interface for users to access the categories.
The Barn 2 Media Hide Categories plugin does all of the above at a very reasonable cost, so unless you only want to hide a few products from some specific customers we would definitely recommend taking a look at this plugin.
Is There A Free Version Of This Plugin?
Barn 2 does not supply a free version of the plugin, but they do provide a no-quibble 30-day guarantee, so it is possible to try the plugin and then get a refund if it does not suit your needs.
As with all Barn 2 plugins, copious documentation and a demo site are provided so it is possible to learn an awful lot about the plugin before you buy.
How Can I Hide Categories Using the Plugin?
After the plugin is installed the following options appear on the edit screens of each WooCommerce category
The behavior of each option is as follows –
Public – The default behavior, if this option is chosen then the category will be visible as normal
Private – If this option is selected then the category will only be shown to the users in groups who have access to private posts, typically this will be any users that belong to the “Administrator” and “Store Owner” groups.
There’s a good tutorial on the Barn 2 site that describes how you can create additional roles with the ability to read private posts using the “User Role Editor” plugin.
Protected – If this option is chosen then the plugin provides three methods for hiding categories –
- Password protection
- Role-based protection
- User-based protection
We’ll take a look at how each method works below
If the password option is chosen then the plugin provides a text box for the admin user to supply a password with which to protect the category
Note the “+” symbol next to the password field, this allows the admin user to set more than one password against the category.
It’s useful to have this feature so you can provide different passwords to different customers, this means that if you have to revoke a customer’s access you won’t have to provide a new password to everyone else. You can just delete the password for the affected customer and everyone else can carry on as normal.
It’s worth noting the plugin does not track which customers are assigned to which password so you will need to keep track of this manually.
Once a password has been set against a category, then any user’s attempting to access the category page or any sub-categories or products that belong to the category will be greeted with something that looks similar to this.
Users will then be able to login using the form and get access to categories/products.
It is possible to change the text on the login screen from the plugin’s admin settings
Most of the fields in the screenshot above are self-explanatory, the one field that maybe needs a bit of explanation is “Password expiry” this allows the admin user to set how long a user can see protected categories after they have successfully entered a password. So, if this value was set to “10” a user would see protected categories for 10 days after entering a password, the categories would then become hidden again and the user would need to re-enter a password.
Showing the Password Form On a Page In your Store
If you would like to include the login form on a page or post in your site then you can do so by adding the following shortcode
This will display the login form using the placeholder text defined in the site’s admin area if you wish to change the form text for each page then it is possible to define the text used in the shortcode itself. Details of all the available shortcode attributes can be found here.
At this point, you may be wondering where the user will be redirected to after entering a valid password on a page containing the shortcode.
The answer is that the user will be redirected to the category page that corresponds to the password entered. So if the music category was protected with the password “vinyl” a user would be redirected to the music category page after entering “vinyl” into the password field.
Visibility of Categories Protected by Passwords
By default, the plug-in will continue to show protected categories/products everywhere in your store and it is only when users click on a hidden item that the password dialog will show.
If you wish to hide protected categories completely then the plugin provides an option in the settings
If this option is unchecked then protected categories will be hidden completely from the store and users will only be able to access them by firstly visiting a URL where they enter a password, all categories that are unlocked by the entered password will then become visible.
If the “User roles” option is selected then the plugin provides a field to list the user roles you wish to allow access to the category
Clicking in the field allows the admin user to choose the roles they wish to add
Multiple roles can then be selected and they will be added to the User roles field
The plugin does not allow and admin user to create new users, so you would need to install an additional plugin such as “User Role Editor”
in order to achieve this.
Once the user roles have been linked to the category, then categories are hidden much like they are for password-protected categories.
The difference between hiding categories by password and hiding by user rules is where you get redirected to when you are not able to access a category.
Give that a password is not required for categories hidden by user role it is not viable to redirect users to a password screen, instead the plugin provides a set of options where a user can be redirected to –
Let’s quickly go through each of the options –
Show 404 error – If a user clicks on a category that they don’t have access to then they will be taken to the sites 404 page, this is the same page a user would hit if they visited a page on the site did not exist.
Show WordPress login page – The user will be redirected to the standard WordPress login page.
Show custom page – You can choose a custom page on your site to redirect the user to. This is an interesting option as it allows you to upsell on the custom page, for instance, you could use the page to sell access to protected categories if it fits with your business model. The plugin allows you to set a custom page for each protected category as well, so this could be quite a powerful feature to generate sales.
Finally, the admin screen pictured above is a little confusing as it has the text “When logged out” next to the drop-down, the choice you make here will apply to both logged in and logged out users. So for example, if the “Show WordPress login page” option had been chosen and a category was only available to “admin” users and a user with a customer account was logged into the store they would still be shown the login page when trying to access the protected category.
If you wish to show a category based on user id the plugin has you covered.
As the screenshot above shows you can choose specific users via a drop-down search that can be filtered by typing in user names.
Once you have specified the users you wish to show the category to, then the visibility of categories and the pages shown to users who can not access categories are controlled in the same ways as discussed in the password and user role sections.
It is also worth pointing out that the plugin allows you to control access to a category via all three methods, so you could only show a category to a specific user that belonged to the specified role and used the correct password to access the category.
How Much Does It Cost
Barn 2 operates a pricing model that allows you to choose between yearly and lifetime pricing, if you choose the lifetime option you are covered for updates and support for the lifetime of the product. If you choose yearly you are charged a fee on an annual basis, this option allows you to cancel your subscription at any time. If you do choose to cancel you’ll be able to continue using the plugin but you’ll no longer receive updates or support.
For a single site on an annual plan the plugin costs £69, it is £209 for a lifetime license for a single site.
For a 5 site license, the plugin costs £129 for an annual license and £389 for the lifetime option.
Finally, aimed at the agency customer, Barn 2 offers a license that will cover up to 20 sites, this license costs £259 per year or £779 for lifetime access.
If you want to hide categories in your WooCommerce store and you require a degree of flexibility across a number of categories then we would definitely recommend you take a look at the Protected Categories plugin.
Whilst snippets can give you a degree of control over what categories are displayed the plugin provides a much more expansive and user-friendly solution.
If you have any questions about the plugin or our review the please don’t hesitate to let us know in the comments.