Shortcode for content view access restriction

Shortcode for posts/pages content view access restriction is available at User Role Editor Pro starting from version 4.7. Enclose restricted content with these shortcodes:
1) [user_role_editor roles="role1, role2"] some restricted content [/user_role_editor];
2) [user_role_editor except_roles="role1, role2"] some restricted content [/user_role_editor];
3) [user_role_editor users="user_id1, user_login1"] some restricted content [/user_role_editor];
4) [user_role_editor except_users="user_id1, user_login1"] some restricted content [/user_role_editor]
and you will restrict access to the part or the whole content of any post or page.

roles attribute: restricted content will be available for the logged-in user with one of the roles you input for the roles attribute of the [user_role_editor] enclosing tag. You should input the role identificator, not the role name. For example, valid shortcode will be [user_role_editor roles="contributor"], not [user_role_editor roles="Contributor"]. Pay attention to the lowercase 1st letter at “contributor”.
For all other users including the guest visitors restricted content, enclosed by the shortcode described above, will be hidden.
If you wish to show some content for not logged in (guest) visitors only, use this shortcode [user_role_editor roles="none"].

If you use a comma ‘,’ sign as a separator inside roles list: “role1, role2”, then ‘OR’ rule is applied: users with role1 OR role2.

If you use a ‘&&’ signs as a separator inside roles list: “role1 && role2”, then ‘AND’ rule is applied: user with role1 AND role2 simultaneously.

except_roles attribute: To show content inside shortcode to all logged in users except users with selected roles, included them into the ‘except_roles’ attribute. For example, if you don’t wish to show some text to the ‘subscriber’ role and other not logged in visitors use this shortcode:
[user_role_editor except_roles="subscriber, none"]some text to hide from subscribers[/user_role_editor].
‘none’ is a virtual role ID used by URE for not logged-in users

users attribute: To show content inside shortcode to logged in users with user ID or login inside comma separated list you can use this shortcode:
[user_role_editor users="18, 23, willy"]some restricted content[/user_role_editor]

except_users attribute: To show content inside shortcode to all users except users with user ID or login inside comma separated list you can use this shortcode:
[user_role_editor except_users="17, 25, peggy"]some restricted content[/user_role_editor]

In order to take into account not logged-in visitor you can use ID=0, like:
[user_role_editor except_users="0, 23, willy"]some restricted content[/user_role_editor]. This shortcode will show content inside to all logged-in users except user with ID=23 and user with login ‘willy’.

Other shortcodes enclosed inside User Role Editor shortcode are processed recursively.

Share