It is easy to show exclusive content for different users on your site. We have already shown you a snippet which allows you to add a shortcode and show content only for logged in or logged out users. But what if you want more control over it?
In this article, we are about to show you User Specific Content plugin which will allow you to create special content for specific users. You can choose users by their names or select user roles for which the content will be shown.
You can select any number of users and user roles, and the plugin will check if they match the criteria for displaying a message. If a user is on the list, the content will be shown while the other folks will get a message you can customize on the plugin’s settings page.
- Go to Plugins->Add New
- Search for “User Specific Content”
- Install and activate the plugin
- Open new post or edit an old one
- On bottom of the page, search for “User specific content box”
Here you will find several options:
- By User Role – select a user role which will have access to the post/page content
- By User Name – select a username which will have access to the post/page content
- Members and Guests – choose if you want to show the post/page only to logged in or logged out users
- Content Blocked Message – write a message which will be shown to anyone who doesn’t meet the criteria above
If you want to have even more control over the content, and for example, show only one sentence to logged in users, to administrators or to specific users, you will have to use shortcodes provided by the plugin.
Limit content for specific users:
[O_U user_id=”1, 2, 3″]Write something in here. This will be limited only for users with user_id=”1”, “2” and “3”[/O_U]
Limit content by specific user names:
[O_U user_name=”Dave”]Content goes here[/O_U]
Limit content by user role:
[O_U user_role=”Administrator”]Content goes here[/O_U]
Limit content to logged in users:
[O_U logged_status=”in”]You only see this if you are logged in[/O_U]
Limit content to logged out users:
[O_U logged_status=”out”]You only see this if you are logged in[/O_U]
You can use more than one shortcode on the same page so you can easily combine user names and user roles or anything else you like. If you want to specify the blocked message for a specific shortcode, simply add the following in your shortcode: blocked_meassage=”write something here”. For example:
[O_U user_role=”Author” blocked_meassage=”Sorry, only authors can read this because they’re so cool.”]Hey, authors. You’re cool![/O_U]