18 Jun, 2008 in Uncategorized by rexreed

New WordPress Plugin: Show User Level Content

UPDATE: Download is now available from the Wordpress.org Plug-In site. You can now download the plug-in at the Wordpress.org site!.

Like many WordPress users, I often have the need to segment my content for different user audiences. While plugins like Post Levels and Disclose Secret are good ways of hiding entire posts from users that don’t meet a certain minimum user level, I couldn’t find a good plugin that did that for parts of a post. I did manage to find a few that would hide parts of a post from unregistered users, but not one that would give you control over which user levels could see that post.

To meet that need, I created the Show User Level Content plugin. This plugin is quite simple. If you want to make a certain part of your content accessible only to users of a specific user level, enclose them with the tag where <level> is the user level. End the section you want to hide with the tag .

Sorry, you can't see this unless you are at User Level 2 or greater

will show the encapsulated content to users of level 2 or higher.

I based this plugin on another plugin that simply used the [hide] tag without the <level> modifier, but I can’t remember where I saw the code for that. If you wrote that plugin, let me know, so I can give you credit!

Installation:

Simply copy the attached file to your /wp-content/plugins directory. Go to the Plugins configuration page in WordPress, and activate. That’s it.

Customization:

If you want to customize what text users see when they are unable to view the privileged content, go to the Plugins administration page and you should see a page for “Show User Level Content Configuration”. Click on that link and you will be taken to a page where you can customize the “exception text”. This is the text that will replace the hidden text users can’t see.

Compatibility: I built this on and for WordPress 2.5.1. I’m not sure if it will work on older versions. I’ll try to keep it up to date for future versions.

Download:

Click here to download the Show User Level Content plug-in.

Feedback:

This is just a version 0.1 plugin! I’d love your feedback to help me make this better. If you know of a better plugin than this one to accomplish what I’m doing, please let me know ASAP so I don’t have to continue development ;)

Contribute: Hey folks, I’m doing my best to keep my head above water and allocate my time to the most valuable tasks. Some of the other plugins in this area have died because no one cared enough to let the author know its value. The best way to let me know is to contribute to my Muse fund on the right side of this blog. Check out the Chip-In widget in the right sidebar, and please chip in. $5 goes a long way to help keep things running!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Furl
  • ThisNext
  • MisterWong
  • Wists
  • Technorati
  • NewsVine
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon

27 Responses so far | Have Your Say!

  1. kat - Gravatar

    kat  |  June 19th, 2008 at 10:39 am #

    the download does not work :(

  2. rexreed - Gravatar

    rexreed  |  June 19th, 2008 at 11:10 am #

    Fixed the download link -sorry about that!

  3. Troy - Gravatar

    Troy  |  June 30th, 2008 at 8:00 am #

    Great idea, but why levels? why not roles or categories?

  4. Dustin - Gravatar

    Dustin  |  July 6th, 2008 at 9:02 pm #

    Hello, would you be able to make it so that you can restrict a page to only certain users by entering their username?

    I’d like to make a page for each user to show them user specific content/documents/links but cannot allow others to view their page of documents.

  5. solzenic - Gravatar

    solzenic  |  September 18th, 2008 at 8:33 am #

    hi, could you repair the link, please.

  6. chase - Gravatar

    chase  |  October 17th, 2008 at 6:25 pm #

    Anyway you can fix the link so we can use your plugin?

  7. carlnunes - Gravatar

    carlnunes  |  December 2nd, 2008 at 3:26 am #

    Sounds good! Can I check the plugin?

  8. rexreed - Gravatar

    rexreed  |  December 7th, 2008 at 12:15 pm #

    Hi all! Great news – I was able to get the Show User Level Content plug-in up at the Wordpress.Org plug-in site.

    I will update this page, but you can now download the plug-in at the Wordpress.org site!

  9. Okoth - Gravatar

    Okoth  |  January 16th, 2009 at 2:32 am #

    Wonderful plugin, Rex. I am using Wordpress 2.7 and it works like a charm!

  10. Okoth - Gravatar

    Okoth  |  February 2nd, 2009 at 4:28 am #

    Sorry, I have to correct myself. In Wordpress 2.7, the [hide ] and [/hide] work only with the first part I want hide. When I use the [hide] and [/hide] later on in the same text, people who are not logged in can see [hide ] and [/hide]… :(

  11. rexreed - Gravatar

    rexreed  |  February 4th, 2009 at 1:21 pm #

    Hello Okoth — thanks for pointing out that bug! I’m going to try to fix it this weekend. Stay tuned.

  12. Penny Haynes - Gravatar

    Penny Haynes  |  March 19th, 2009 at 12:09 am #

    Rex, you are a genius, as I’ve been killing myself to figure this out, but I need some additional help to apply your functions to another plugin. I am willing to pay you to help me just understand your plugin and how I can integrate what you have accomplished to put it into another plugin to stop it from showing a feature if the User isn’t logged in and isn’t a Contributor.

    Please contact me asap about this. Thanks in advance for your help!

  13. Penny Haynes - Gravatar

    Penny Haynes  |  March 19th, 2009 at 12:19 am #

    Actually, I’ve tried the plugin, and it’s not really working for me, but I still need your help and am willing to pay you to help me figure this out and understand the wp functions so I can access them.

  14. rexreed - Gravatar

    rexreed  |  March 19th, 2009 at 6:01 pm #

    @Okoth — Fixed the problem with multiple [hide] statements. I’ve updated the plugin. Check it out at:
    http://www.fourhourworkweekdiary.com/2009/03/19/testing-version-02-of-show-user-level-content-plugin/

    It might take a few hours for the Plugin repository to kick in. You’ll know you have the updated version if the version is 0.2 in the repository and in your WP plugin manager. Drop me a note if this works for you.

  15. rexreed - Gravatar

    rexreed  |  March 19th, 2009 at 6:10 pm #

    Penny – not sure I understand what is not working for you. I’ve dropped you an email, so please respond with how I can help. Which other plugin are you trying to apply this to?

  16. JC - Gravatar

    JC  |  April 27th, 2009 at 9:12 am #

    I just installed this onto 2.7.1 of Wordpress and gave it a little test. All I am seeing is the tags for [hide][/hide] – whether logged in or not and it doesn’t hide anything. I set the user level to 0 – I assume this is the level that it should be hidden for ?

    But in any case not working here. Some more detailed documentation would help as well, I notice with a lot of plug-in authors you don’t get a lot of people giving detailed documentation on usage. Perhaps this plug-in works however with the lack of usage guidelines other than what has been mentioned I haven’t seen this working. The settings area and explanation on how to configure it is vague as well and should be explained more. Sorry for the critique but I just wanted to give an honest view of what I find as an end user difficult to understand about this.

  17. DavyB - Gravatar

    DavyB  |  April 30th, 2009 at 9:58 pm #

    seems to duplicate the hidepost plugin which does have levels and can hide link addresses also. and is known to work with 2.7.1 and the displayed messages can be configured or made to be blank.

    [hidepost]logged in can see this[/hidepost]

    [hidepost=2]user with level 2+ eg author can see this [/hidepost]

  18. mssmotorrd - Gravatar

    mssmotorrd  |  May 3rd, 2009 at 7:55 am #

    It’s the first time I commented here and I must say you share us genuine, and quality information for bloggers! Good job.
    p.s. You have a very good template for your blog. Where did you find it?

  19. rexreed - Gravatar

    rexreed  |  May 18th, 2009 at 3:30 pm #

    Hi JC –

    Thanks for your comment. I’m trying to diagnose this problem, as I can’t seem to replicate it here. Do you have a post where you are trying to use the plugin? Also, did you indicate a User Level at or above which the text will be hidden?

    For example, the usage of
    [hide 2] This text is hidden for those below level 2[/hide]

    Will hide the text for those levels not logged in, or those logged in, but below user level 2.

    Can you see if that works for you? I need a good plugin to show the code, so that it doesn’t actually try to execute it on the site.

    Thanks,
    Rex

  20. rexreed - Gravatar

    rexreed  |  May 18th, 2009 at 3:31 pm #

    @DaveB – good post. At the time, that plugin didn’t exist, but I will take a look at it now. Anyone have good feedback on that?

  21. Hema - Gravatar

    Hema  |  July 5th, 2009 at 4:54 pm #

    Yes, that what i need,
    with this plugin i can make membership site with wp
    Thanks rexredd
    feedback after installation

  22. Hema - Gravatar

    Hema  |  July 5th, 2009 at 5:38 pm #

    Iam sorry rexredd, if you still support plugin
    i have a blog for downloaded links and i want to hide links from visitors , to be only available for registered users
    i use wp 2.8
    i tried all codes but not working
    have u any suggestion for code?
    Thanks

  23. Kirk Ward - Gravatar

    Kirk Ward  |  December 28th, 2009 at 12:04 pm #

    Hi Rex,

    I want to use this plugin with a membership plugin called “WishList Member.”

    Would like assistance in setting your plugin to work with theirs.

    Are you available for custom coding or mods?

    Kirk

  24. rexreed - Gravatar

    rexreed  |  December 29th, 2009 at 4:39 pm #

    Hi Kirk —

    Good to hear from you. I’ve actually made a number of significant improvements to the Plugin – I’ll post about it later this week. In the meantime, can you let me know how the existing plugin is not working with the plugin you mention? Also, can you post a link to the plugin you’re talking about above?

    Tnx!

  25. Jason - Gravatar

    Jason  |  January 12th, 2010 at 8:20 pm #

    Hi Rex,
    I hope that you can somehow merge your plugin with WP-Sentry.

    I like the idea of hiding contents to those who aren’t registered and logged in, but it’ll be even greater to hide specific contents to specific group users. I had communicated with Pete Holiday, the developer of WP-Sentry, and he mentioned that he can incorporate such features but it wouldn’t be fail-safe if the plugin fails.

    Therefore, I’m wondering if you might have a different approach to this problem. Your suggestions will be valuable in enhancing either plugins further.

    Cheers,
    Jason :-)

  26. Tony - Gravatar

    Tony  |  March 8th, 2010 at 1:57 pm #

    Hi there, I had a question for you…

    From what I’m reading this decides what to show based upon levels that are equal to or less than. Meaning someone of level 5 will see anything less than their level.

    Is there a way to show something only to an EXACT level? Like content a to level 3, and content b to level 4, etc. In this case, level 5 would not see these as it is not specifically level 3 or 4.

  27. rexreed - Gravatar

    rexreed  |  March 8th, 2010 at 2:45 pm #

    Yes, in fact, I have a new version of the plugin! I will be posting it shortly, and it has a lot more features including using operators (> and <), allowing multiple hides and using names of roles instead of access levels. I hope I can post it by Friday – stay tuned!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>