Do you want to easily hide products by user roles in WooCommerce?
Some WooCommerce store owners have a unique requirement where they want to hide certain products from all but a few specific groups of users. There may be many reasons for this, including selling exclusive products only to the more loyal customers, with a membership.
In fact, a more general use case of restricted product pages can also be when the store owner wants to run offers for their premium members only. They may want to sell some of their best products at a discounted price to them.
Whatever the reason, it’s important to be able to manage product visibility by user roles for WooCommerce.
Profile Builder Pro is designed to offer this functionality, along with many other useful features that help with the user management of your WooCommerce website. And it can do it for free!
Profile Builder Pro
Restrict product pages by user roles the way you want easily, quickly and with all possible customizations.
How to Hide WooCommerce Products by User Role Using Profile Builder
Now that we have revealed that Profile Builder is the solution you’re looking for to manage user-specific products on your WooCommerce website, let’s take a quick look at the steps involved in the process:
- Enabling content restriction functionality in Profile Builder;
- Choosing the type of restriction you want to use by default;
- Applying custom restriction settings to individual products. This is used when you might want a custom individual type of restriction instead of the default one.
So, let’s break these steps down into more actionable explanations so that you can follow along and hide specific products from the shop page on your WooCommerce site with ease.
Activate the Content Restriction Functionality
Before we get to hiding WooCommerce products, you’ll first need to install and activate the Profile Builder plugin on your WordPress site. You can download it for free from WordPress.org and then install it from Plugins → Add New → Upload Plugin in your WordPress dashboard.
The content restriction functionality is disabled by default in Profile Builder as not all websites are going to need it. So, in order to hide products by user role in your WooCommere store, you need to activate it first.
Click on the Settings option under the Profile Builder menu on your WordPress dashboard. Then click on the Content Restriction tab at the top. It’s the first option under that tab – Enable Content Restriction – that you need to set to Yes. So, click on the drop-down list and choose Yes.
Set Up Default Content Restrictions
On this same page, you can also choose the type of content restriction that you want to be used by default. This content restriction type will be applied site-wide to all products/posts/post types where the functionality is enabled without any customization. This includes the product pages where you leave the Settings Default option selected. But we’ll get back to this later.
Now, if you choose Message as your preferred type of restriction, by default, Profile Builder will show a message on restricted product pages. However, you can customize this message and make it your own if you scroll down a bit on this page.
Alternatively, you can choose to redirect all visitors on restricted product pages to a page of your choice. It can be a membership page or pretty much anything you want it to be. Just click on the Redirect option and paste the URL of the page you want the visitors to be redirected to.
Once you’re done customizing the settings you want, you can scroll down to the end of the page and click on the Save Changes button. This will enable the content restriction functionality on your WordPress website.
Now you know how Profile Builder’s content restrictions work, but it’s time to learn about using your website’s user roles to implement these restrictions.
Hide Individual WooCommerce Products by User Roles
As I said above, Profile Builder is one of the most flexible user management plugins out there. It offers an incredible amount of customization and flexibility with pretty much all of its features.
That being said, when looking to use WooCommerce to hide products by user roles, the plugin offers a special meta box at the end of every product page where you can set this functionality up. There are 3 different types of content restrictions that you can apply to your individual WooCommerce product pages to hide them based on user roles. They are all designed to achieve different end goals. So let’s walk you through them below.
First things first, in order to access the Profile Builder Content Restriction meta box, you’ll need to navigate to the product page that you want to hide from the back-end and scroll all the way down. You’ll find this content restriction box at the end of every product page. Here, you can choose from the 3 different content restriction settings available.
Settings Default – Using General Content Restriction Settings
The first option when customizing individual product restrictions is Settings Default. This option will be chosen by default and will apply the default settings you have previously set in the Content Restriction tab from Profile Builder’s general Settings presented above.
It can be either to show a message on restricted product pages or to redirect them to a particular page, depending on what you have chosen there. This will save you a lot of trouble, not having to individually update every product’s content restriction settings.
However, you’ll still be able to customize the content restriction settings on individual products if you want to. So again, if you don’t want to individually customize a specific product, don’t make any changes here and the default settings will apply to that product page.
Showing a Default or Custom Message
The second option here is Message. This simply allows you to show either the default or a custom message on that particular product page for the restricted users. Choosing this will overwrite the default content restriction settings you may have set in the general settings.
So, for example, even if you have chosen the Redirect option in the general settings of Profile Builder, you can choose the Message option here to show the default or custom message on this particular product page.
If you want to have a custom message instead of the default message on restricted products, you can write it in the custom message section:
As you can see, you also have the ability to choose a different message for logged-in users and logged-out users, by writing a unique message in each of the fields.
Select User Roles and Grant Access
Now speaking of users, the next step for fully customized product restrictions by user role, is to actually select the users you want to keep out of your specific product pages.
So, right after the Type of Restriction section, you’ll find the Display For section. Here, you can choose the user roles that you want to allow access to the product page you’re restricting. Once you click on the ‘Logged In Users’ checkbox, you will be able to select any other specific user role to allow them access to the product. These can include the Administrator, Author, SEO Manager, SEO Editor, Shop manager, or any other user role you have set up on your website.
The user roles that have remained unchecked won’t be able to see that specific product. They will either get the default restriction message (or a custom message set by you), or get redirected to a page of your choice, depending on the settings you choose.
And since we’re on the topic, with Profile Builder you can even create your own custom user roles or edit the already existing ones. This way you can personalize the user experience even more.
Redirecting Restricted Users
That brings us to the Redirect option. Again, you can choose which user roles can access the product and which user roles get redirected to some other page, just like I’ve shown you above. If you choose to create new user roles, those will then appear in the Display For section of the meta box.
So again, for example, if some of your product pages need updating or optimization by your team, you can allow those user roles access to those products, while restricting it for all the other user roles.
Similarly, you can use the Redirect setting option to redirect the restricted users to a page telling them that the product will be available soon. Of course, you can also just as well redirect them to a similar product that they may be interested in.
You can also choose a custom redirect URL here even if you have a default redirect URL saved in the settings.
Once you’ve chosen your settings, scroll back to the top and click on the Update button for your changes to take place. That’s it! You have successfully applied your product restriction settings.
To confirm that the product restriction has actually come into effect for the specific WooCommerce user roles, you can visit the restricted product page as one of the restricted users. In my example, this is what a user role with no access should see if I choose the Message restriction type:
Other Important Content Restriction Features
We have covered most of the content restriction functionality of Profile Builder that helps you manage product visibility in WooCommerce. However, Profile Builder has more to offer.
There are also some advanced content restriction functionalities that you can use in specific cases. They can also help convert more users into premium members if that’s what you’re looking to achieve.
So with that said, let us also take a look at those advanced functionalities.
Adding Media in Default Content Restriction
When you edit the default content restriction settings as explained above, you can also make use of media. This means that you can display an image or a video instead of text informing the users about the hidden WooCommerce product.
Of course, this would only work if you’re choosing the Message option. With the Redirect option, you can have your media elements embedded on the redirected page itself.
The same goes when updating restriction settings for individual products. You can choose to add media to your custom restriction message. In addition to this, when talking about product page content restrictions, you can also add a form that will only be displayed to restricted users. You can do this if you have a contact form plugin installed on your WooCommerce website. However, you do need to have a form created through your contact form plugin to be able to do so.
This functionality would allow you to get the details you want of users that land on restricted product pages. You can notify them when you can offer those products to them again, or even offer them some other similar products depending on their interest.
You can use Profile Builder’s Mailchimp integration add-on to send emails to these users as well.
Start Hidding Products by User Role in WoCommerce Today
Finally, Profile Builder Pro comes with a whole lot of other user management features outside of content restriction. Some of them include:
Give Profile Builder Pro a try if you’re looking for the most seamless and effective way to manage users on your WooCommerce website. Or download the free version if custom forms and content restrictions are all you need.
Profile Builder Pro
Restrict product pages by user roles the easy way, quickly and with all possible customizations.
Do you still have questions about how to hide WooCommerce products by user roles? Ask them away in the comments below!
Source: https://www.cozmoslabs.com/382891-woocommerce-hide-products-by-user-roles/