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) 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 at the readonly textarea was updated.
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.

The example of using this feature with WooCommerce products and categories:

WooCommerce products – restrict view by category

Role level restrictions

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

Content view restrictons for roles
Content view restrictions for roles

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.

  • Zach Bennett

    Would it be possible to use this feature to restrict access to static HTML pages and their supporting assets (JS, CSS, images, etc)? I want to store my content somewhere it can’t be accessed publicly, then only serve those pages to my WP users who are logged in and have the proper roles.

    • This feature protects WordPress pages by URL. If user does not login or has no required role he can not open protected page.
      If user knows direct link to JS, CSS or image files, he may download it without login even if page itself is protected.