User specific content plugin

User specific Content Plugin

So i saw a question on WordPress Answers that asked

how to display user specific content?

and i remembered that i have coded something like this before, So after a few hours of search my code and snippets files I've found it, Fixed it up a bit and now you can use it. presenting User specific Content


What does it do?

This Plugin allows you to select specific users by user name, or by role name who can view a specific post content or page content.

How does it work?

Basically it adds a meta box to the post or page edit screen and lets the user select specific users by name or roles and then when you call that page content using "the_content();" function it check using "the_content" filter if the current user is one of the users you have selected or if his role match's the roles you have selected and shows the content, otherwise it displays a message which can be set in that metabox, something like:

Sorry But This Content is for specific Users Only, Maybe log-in???


  • You can select any number of Users you want by there names.
  • You can select any number of users Roles you want by there names.
  • Easy Customization of content blocked massage.


Download the latest Version from

Simple Installation steps:

  1. Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation.
  2. Then activate the Plugin from Plugins page.
  3. Done!


Simply create or edit post/page and you will see the User Specific Content metabox where you can select your option, then save and that is it.


Since Version 0.7 the plugin comes with a new shortcode (the idea cam from your great feedback and comments) which extends the plugins functionality.
Basic usage of the shortcode:

[O_U user_id="1"]Content goes here[/O_U]

where 1 is the user id. or to specify multiple users you can use:

[O_U user_id="1,2,3"]Content goes here[/O_U]

To limit content by user name use:

[O_U user_name="Bainternet"]Content goes here[/O_U]

where Bainternet is the user name. or to specify multiple users you can use:

[O_U user_name="Bainternet,Steve,david"]Content goes here[/O_U]

To limit content by user role use:

[O_U user_role="Administrator"]Content goes here[/O_U]

where Administrator is the user role. or to specify multiple user roles you can use:

[O_U user_name="Administrator,Author,Contributor"]Content goes here[/O_U]

To change the blocked massage use:

[O_U user_role="Administrator" blocked_meassage="admins only!"]admin content goes here[/O_U]

You can also use the shortcode more then once in a single post:

[O_U user_role="Administrator"]admin content goes here[/O_U]
[O_U user_name="Bainternet,Steve,david"]specific users content goes here[/O_U]

And best of all you can even use it as a template tag:

<?php echo do_shortcode('[O_U user_role="Administrator"]admin content goes here[/O_U]'); ?>

this is it, enjoy and any feedback is welcome, also make sure to submit bug if you find any.

Change Log:

  • 0.9
    • Added nested shortcode support, which means you can filter who sees your shortcodes
  • 0.8
    • quick bug fix., thanks to Amuras comment.
  • 0.7
    • Major update, Plugin rewritten in OOP.
    • New shortcode implemented.
    • New options panel to define User Specific MetaBox.
    • New admin panel.
    • Run filter on the_content as well as the_excerpt.
  • 0.6
    • Fixed all wp_debug warnings.
  • 0.5
    • Quick fixed WP_Debug warnings.
  • 0.4
    • added simply logged-in user content only!
    • quick fixed block by role bug.
  • 0.3
    • Added support for none logged in users content only.
  • 0.2
    • Added page support
  • 0.1
    • Initial release

Ohad Raz

WordPress Consultant, a WordPress Developer and a WordPress Freelancer With over 10 years experience in architecting web sites and applications. WordPress Development moderator and somethimes Plugin Developer.