Content view access restriction for selected roles

Activate “Content View Access Restrictions” module at User Role Editor Settings page:

Content view access restrictions settings
Content view access restrictions settings

Post level restrictions

If you wish to restrict the post view by users with the selected roles only follow these steps:
1) Open the post for edit, scroll to “Content View Restrictions” metabox.
2) Select a kind of restriction, for whom apply it and what to do in case of access error:

Content view restrictions at post level
Content view restrictions at post level

3) If you selected “For Users” with “Selected User Roles”, click “Edit Roles List” button and select role(s) for which you wish to apply access restriction action. Click “Save” button, check that roles list was updated at the readonly textarea to the right.
Content view access restriction roles selection
Content view access restriction roles selection

Do not forget to click “Update” button to save full changes made to the post including roles list you just built.
Post update
Post update

Done. This post is available for logged-in users with selected roles only. If you selected action “Prohibit”, that this post is available for the all roles except included into the roles list.

Category level restrictons

If you wish to restrict the view of a group of posts at once you may set view restrictions for selected category. Open needed category for editing. You will see the same “Content View Restrictions” section as shown for post above.

content view restrictions category level
Content view restrictions on category level

All posts of this category will have restricted view according to the settings you made here.

Role level restrictions

It’s possible to set content (posts/pages/custom posts types – including WooCommerce products) view restrictions on a role level:
Go to “Users->Users Role Editor”. Select role and click “Posts View” button:

content view restrictons for roles button
Content view restrictions for roles button

At opened dialog select/input appropriate access restrictions options:

Content view restrictions for role dialog
Content view restrictions for role dialog

In some cases it will be needed to allow authors to see just their own posts at front-end. You can achieve that with this settings:
a) Block – Not Selected
b) Own data only – turned ON.

The example of using this feature with WooCommerce products and categories:
Restrict WooCommerce products view by category

Take into account that user by default can view any post/page which he can edit. It’s possible to change this via custom filter ure_restrict_content_view_for_authors_and_editors.

If you are interested how to add content view restrictions for post programmatically read this article.

Share