WooCommerce: hide products by user roles – the easy way

You don’t always want to let all your users see all your products. In this article I’m going to show you how you can hide products by user roles in WooCommerce.
Hide products by user roles in WooCommerce
Let’s imagine that we’ve got certain limited-edition products on our store that we only want to offer to certain customers. One of the easiest ways to ensure that only the right people see these products is to hide them from users who do not have the correct role.
In this article we’ll take a look at some key information, including:
- What are user roles
- How to create new user roles in WooCommerce
- How to automatically assign a user role to a customer
We’ll then walk through:
- How to hide a single WooCommerce product by user roles
- Hiding all products in specific WooCommerce categories by user roles
- Hiding all products in our WooCommerce store by user roles
Finally, we’ll look at some optional behaviours such as:
- Redirecting the user when they try to access a hidden product, e.g. to a dedicated landing page
- Changing the ‘Add to Cart’ button text for our ‘hidden’ products
For all the functionality discussed in this article, you’ll need a copy of WooCommerce Members Only, which is a membership plugin for WooCommerce. This will allow you to hide products by user roles in your WooCommerce store.
By the way, here’s a complete tutorial on how to build a WooCommerce membership site.
And there is a more in-depth article on WooCommerce hidden products here.
What do we mean by ‘hidden’?
Before we start, let’s just clarify what we mean by hidden. A product that is hidden in WooCommerce will not:
- Be accessible directly
- Be present in any archive or shop page (the standard WooCommerce loop)
- Appear in product lists generated using PHP snippets or shortcodes
- Be visible to search engines
How to hide products by user role – video
In case you prefer to watch a video on this topic, take a look at this:
What are user roles?
Roles in WordPress are used to define what individual users can see and do on a site. For instance, a user with the role of ‘Administrator’ can do anything they like – view and edit all content, upload and delete themes and plugins, add and remove other users.
We can use the concept of user roles in our WooCommerce store to give certain customers more rights and privileges than other customers. For example, we could create a user role that allows users to see certain products that would be hidden from other customers.
You’ll find more details about WordPress user roles here.
How to create new user roles in WordPress
The Members Only plugin makes it easy to create new user roles in WooCommerce.
Let’s say we want to create a user role called ‘Star Customers’ who will be entitled to purchase our limited edition products. We’ll hide those products from every other customer who does not have the Star Customer user role.
Creating a new role in WooCommerce
To create our new WooCommerce user role:
- Go to Members Only > User Roles
- Scroll down to the Roles field
- Enter the name of your new rol
- Click the ‘Add role’ button

That’s all you need to do to create your new WooCommerce user role.
Automatically assigning a new user role
Once you’ve created your new user role, you might want to automatically assign it to certain customers – e.g. if they buy certain products.
To find out how to automatically assign a user role to a customer after purchasing a product in WooCommerce, see this article.
With our new user role set up, it’s time to look at exactly how to hide products by user role in WooCommerce.
How to hide a single WooCommerce product by user roles
Let’s imagine that we just have one product that we want to hide from certain user roles. To hide one product:
- Edit the product that you wish to hide
- Click on the ‘Members Only’ tab in the ‘Product Data’ section
- Select ‘By User Role’ in the ‘Restriction method’ field
- Enter the user roles that are permitted to view this product in the ‘User Roles’ field
- Check the ‘Hide in Archives’ box
- Save the product

This will now ensure that this product will be hidden from any users who do not have the ‘Star Customer’ role, including users who are not logged in.
Multiple user roles
Note that you can enter multiple user roles if you wish. The user will just need to have one of the specified user roles in order to view the product.
To enable multiple user roles in WooCommerce take a look at this article on user approvals.
How to hide multiple WooCommerce products by user roles
The simplest way to hide multiple WooCommerce products by user roles is to hide specific categories. This will mean that all products in the restricted categories will be hidden. We do this by first specifying user roles as the restriction method, then creating one or more membership plans to define which categories should be hidden.
To set the restriction method to user roles:
- Go to Members Only > Settings
- Choose ‘User role’ from the ‘Restriction Method’ field

Now you can define a membership plan to set which categories will be hidden:
- Go to Members Only > Plans and click ‘Add New Plan’
- Set the ‘Restricted Content’ field to ‘Product Categories’. (Note that you can add other content types here too, like post categories and post types, if you wish)
- Select the product categories to hide in the ‘Restricted Product Categories’ field
- Finally, in the ‘Permitted User Roles’ field, select which role(s) can view the hidden categories

With these settings, hidden categories will not appear in any category archive, products within the hidden categories will not appear, and products will not be accessible directly.
If you would like to set different user role restrictions for different categories, you can just create multiple membership plans. Each plan can restrict different product categories for different user roles.
Using this method to hide products is also called private or protected categories. There’s a longer article on WooCommerce protected categories here.
How to hide all products in WooCommerce by user roles
So the final option is for us to hide all WooCommerce products by user roles. We might do this because we want to make our entire product catalogue only available to a selected few.
To hide all WooCommerce products by user roles:
- Go to Members Only > Settings and set ‘Restriction Method’ to ‘User role’
- Go to Members Only > Plans and create a new membership plan
- In the ‘Restricted Content’ field, select ‘Post Types’
- In the ‘Restricted Post Types’ field, select ‘Products’
- n ‘Permitted User Roles’ enter one or more user roles that are allowed to view the hidden products

Hiding additional WooCommerce pages
Using this method, all product and category pages will be hidden from the user if they don’t have the correct user role. If you would also like to hide WooCommerce pages like the cart and checkout pages:
- Add ‘Pages’ to the ‘Content Type’ field
- Select which pages to hide in the ‘Restricted Pages’ field, e.g. ‘Cart’ and’Checkout’

Redirecting the user to a dedicated landing page
Now let’s look at some extra options. If a customer tries to access a product page that is hidden, you might want to redirect them to a specific page – e.g. a landing page with further information, or even another product page that will allow them to upgrade their account.
To enable this redirection:
- In Members Only > Plans, edit the membership plan
- Set ‘Landing Page’ to the page that you would like to redirect users to when they try to access hidden content in this plan

If you have more than one membership plan, you can set the landing pages differently in each one. This means that you can direct the user to a different landing page depending on which hidden content they try to access.
Changing the ‘Add to Cart’ button text for our ‘hidden’ products
What if we don’t want to hide the products but just make them so that certain users can see them but can’t purchase them? We can still show the products on our website to tempt those customers who don’t have the correct user role. But we can change the ‘Add to Cart’ button to display some different text. When the user clicks the product, they’re redirected to the landing page – see above.
To change the button text for restricted products:
- Go to Members Only > Settings
- Uncheck the ‘Hide Products in Archives’ setting. This means that products will no longer be hidden in the category and other archive pages
- If you want to allow users to access the product pages themselves (e.g. to view more information), you can enable the ‘Access Product Pages’ setting
- Enter the custom add to cart text in the ‘Add to Cart Text’ field
- If you’d like to redirect the user when they click the add to cart button, enable the ‘Redirect from Add to Cart Button’. This will direct the users to the landing page specified in the membership plan
- Finally, if you’d like to hide the prices from unauthorized users, enable the ‘Hide Price’ option

Check out this article for how to hide the price in WooCommerce.
Hiding products in WooCommerce by user roles
This article should have given you all the information you need to hide WooCommerce products according to user roles.
We looked at what user roles are and how to create them using the Members Only plugin.
We also looked at different options for hiding products – either individually, by category, or globally.
Then we looked at some ways to finesse our site by adding redirections.
I hope you found this useful. Don’t forget to pick up your copy of WooCommerce Members Only.
hello
does the plugin also hide categories in the category listing when all products in this categories are hidden for guest or other users except for a spexific user role for exampe member?
and does it also change the items counter for the category?
Hi Alain
Yes, the plugin will hide categories in the shop and archive pages if its products are hidden for the user. It will also change the counter for the category.
Thanks.
Is it possible to hide certain brands using user roles, ie, rather than restricting a category, I need the ability to restrict certain customers from buying certain brands in states that I do not have resell rights. Thanks.
Hi Kevin
Yes, it’s possible to hide brands instead of a category using a snippet. Our support team can help you with that if you need.
Thanks.