Restrict access to Content

Restrict access to Content by User Role

If you use this shortcode the content will only be visible to the Editor. You can replace the editor with any other user role

[sws_shortcode width=”100%” float=”left” class=”sws_blue”] [/sws_shortcode] [sws_divider_padding]

You can also add the capability view_restricted_content to any user role and then the user with the specific user role can view restricted content. It works with the following shortcode

[sws_shortcode width=”100%” float=”left” class=”sws_blue”] [/sws_shortcode] [sws_divider_padding]

And you can use this for showing content on the page for users that are NOT logged in.

[sws_shortcode width=”100%” float=”left” class=”sws_blue”] [/sws_shortcode] [sws_divider_padding]

And you can restrict content to a specific user role by using the following shortcode. The user role can be replaced with any user role in your site.

[sws_shortcode width=”100%” float=”left” class=”sws_blue”] [/sws_shortcode] [sws_divider_padding]

[pur_restricted alt=”If you have the right access level to this post you can see a picture of the plugin that is used to restrict access to content. This is a really helpful plugin that makes it possible for you to show different content depending on the user role your visitors have.” capability=”editor”]

Congratulations you are logged in as a user with the User Role Editor. This allows you to view the picture below. We have used the Pages by User Role plugin to restrict which users that can view this content.

logged-in-editor

[/pur_restricted]
If you login as an Editor you can see even more content on this page.

Try login using the following information:

Username: Editor
Password: TryMeNow

[pur_restricted] If you can see this line of text it is because the user role that you are logged in as has the custom capability view_restricted_content. This is a great feature that allows you to only show content to user roles with this specific custom capability.

[/pur_restricted]

[sws_divider_basic]

Content shown to users that are not logged in:
[pur_not_logged_in] You can see this content if you are not logged in. [/pur_not_logged_in]

[sws_divider_basic]

Content shown if you are not editor:
[pur_restricted_alt capability=’editor’] If you are not an editor you can see this text. [/pur_restricted_alt]
[sws_divider_basic]

Content shown if you are not administrator:
[pur_restricted_alt capability=’administrator’] If you are not an administrator you can see this text. [/pur_restricted_alt]