1. Home
  2. Documentation
  3. Password Protected Categories
  4. FAQ
  5. How to add and edit WordPress user roles to access private posts, products & categories

How to add and edit WordPress user roles to access private posts, products & categories

Our Password Protected Categories and WooCommerce Protected Categories plugins provide an option to mark categories as ‘Private’. You can also use WooCommerce Protected Categories to choose which WordPress user roles can access specific product categories.

This article will explain how to:

  1. How to edit user roles to access private posts, products & categories (applies to WooCommerce Protected Categories only)
  2. How to edit WordPress user roles and give access to private content (applies to Password Protected Categories and WooCommerce Protected Categories)

How to create new user roles who can access your protected categories

WordPress itself comes with a choice of built-in user roles – Administrator, Editor, Author, Contributor, and Subscriber. WooCommerce adds to extra roles: Customer and Shop Manager.

You can use the WooCommerce Protected Categories plugin to restrict your categories to one or more of these roles. Alternatively, you can follow the instructions below to create additional user roles that can access your protected categories and their products. For example, you might want to create a ‘Wholesale’ user role and use it to create a private wholesale area that only logged in wholesale users can access. You can do this with the free User Role Editor plugin.

  1. In the WordPress admin, go to Plugins > Add New and search for ‘User Role Editor’.
  2. Install and activate the plugin.
  3. Go to Users > User Role Editor.
  4. Click ‘Add Role’.
  5. Choose a slug and name for your new role, such as ‘wholeale’ and ‘Wholesale’. When using this method with WooCommerce Protected Categories, you will normally want to copy the Customer role. This gives the new role the same capabilities as the built-in customer role.
  6. Click the ‘Add Role’ button.
  7. To add users to the new role, go to ‘Users’ section of the WordPress admin, edit the user, and choose the role from the dropdown.
  8. Finally, go to add or edit your product categories, and restrict one or more categories to this new user role.

Create WordPress user role

How to choose which user roles can access private posts, products & categories

Our Password Protected Categories and WooCommerce Protected Categories plugins provide an option to mark categories as ‘Private’. Private categories only appear to logged in users of your WordPress website with the correct role capabilities.

By default, private categories are only visible to Administrators and Editors (plus Shop Managers if you’re using WooCommerce). If you’re using private categories, you will probably want to make them available to other user roles – for example, normal subscribers or customers.

If you’re a WordPress developer then you can change the user roles programmatically. Otherwise, we recommend using the free User Role Editor plugin. The following video tells you how to do this, or you can read the written instructions below:

How to edit WordPress user roles and give access to private content

  1. In the WordPress admin, go to Plugins > Add New and search for ‘User Role Editor’.
  2. Install and activate the plugin.
  3. Go to Users > User Role Editor.
  4. In the ‘Select Role and change its capabilities:’ dropdown, select the user role that you want to access private categories.
  5. Tick the ‘Show capabilities in human readable form’ box.
  6. Lower down, you will see an alphabetical list of all the WordPress user role capabilities. Scroll down to the ‘R’ section and tick the following boxes. (Depending on your plugins, you may not see all these boxes, and there may be similar ones that you need to tick too. Don’t worry about this – just tick the boxes that apply to your site):
    • Read private pages
    • Read private posts
    • Read private products
  7. Scroll up and click ‘Update’.
  8. Create a private category, login as a user with the role you just edited, and check they can view the category ok.

Tip: If you get a 404 error, this means that the user doesn’t have access to the private category. Go back and check your changes, e.g. make sure you edited the correct role.

Edit WordPress user roles for private categories, posts and products

How can I create password protected categories in WordPress?

Once you’ve given your users access to private content, you need to mark the relevant content as private. Private pages, posts and individual custom posts are already built into WordPress. To mark entire WordPress categories as private, and all the posts within them, you need our Password Protected Categories or WooCommerce Protected Categories plugin.

Was this article helpful?

Related Articles