Skip past navigation, straight to the content

Introducing the Post Levels plugin

Post Levels is a Wordpress plugin which allows you to restrict access to posts based upon the user level. Wordpress 1.3/1.5 or greater required.

Version 0.1 is available for download: Post Levels Plugin v0.1

Install

  1. Save the post-levels.php.txt as post-levels.php file to your wp-content/plugins/ directory
  2. Activate the plugin within Wordpress in the Plugins section

Use

  1. Set the Post Status to Private: This ensures your post will not be shown if the plugin is accidentally disabled
  2. Add a Custom Field named post_level
  3. Set the value of post_level to a number between 1 and 10: Only registered users with a level greater than or equal to the post_level will be able to see your post.

Known Issues

  • Archive and Category Post listings do not include private posts

40 Comments

  1. T

    Like the View Levels plugin, only much much hotter?
    http://www.furbona.org/viewlevel.html

    Posted Jan 30, 2005 at 9:11pm | Permalink
  2. Yes, the Post Levels is a bit faster and ensures that posts aren’t shown if the plugin is disabled; however, it doesn’t work in WP 1.2

    Posted Jan 31, 2005 at 11:03am | Permalink
  3. Sine

    I have tried to install this several times, each time I activate it all it does is show at the top of every page all the coding. It there somthing else that has to be done?

    Posted Feb 11, 2005 at 5:42pm | Permalink
  4. I’ve never seen the error, but here’s a guess: Have you made renamed the file to post-level.php? You have to make sure there isn’t an “s” at the end of the file extension.

    If that’s not the case, which version of WordPress are you using? This plugin doesn’t work with version 1.2, but it shouldn’t show the source code.

    Posted Feb 12, 2005 at 3:44pm | Permalink
  5. Nevermind, I found the issue — saving the phps file directly actually gives you an HTML document [php's automatic source color coding]. You can either copy-paste the file contents, or re-download the plugin (I’ve removed the color coding).

    Posted Feb 12, 2005 at 4:13pm | Permalink
  6. Shelby

    Are you working on getting the Archive / Category listing to show the posts? Also anyways to make protected posts SHOW they are protected eg. with the little padlock like “View Levels plugin” .. other than that sweet plugin thanks and keep up the good work

    Posted Feb 16, 2005 at 4:24pm | Permalink
  7. Unfortunately, Wordpress doesn’t provide the right hooks to fix the Archive / Category listing, which makes it difficult to incorporate that within a plugin.

    I’ll add support for displaying a “private” icon in the next version of the plugin.

    Posted Feb 16, 2005 at 9:33pm | Permalink
  8. Shelby

    Man that sucks with Wordpress. And I will be looking forward to the next version, thanks again and keep up the good work.

    Posted Feb 17, 2005 at 9:20am | Permalink
  9. Shelby

    Man that sucks with Wordpress. And I will be looking forward to the next version, thanks again and keep up the good work.

    Posted Feb 17, 2005 at 9:24am | Permalink
  10. iðunn

    hello and thanks for releasing this into the wild … however I’ve noticed that the entries that I’ve marked private and also set a post_level, these entries still appear on RSS-feed lists.. any idea how to fix that? :-)

    Posted Feb 17, 2005 at 2:57pm | Permalink
  11. Actually, they only appear in the RSS feed if the feedreader you’re using is either an in-browser one, or somehow uses your cookies. Try logging out of your browser (or using a different one) and visiting the feed URL, and you’ll notice that the private posts are not shown.

    Posted Feb 17, 2005 at 4:40pm | Permalink
  12. iðunn

    oops, I spoke to soon. the posts don’t show up in the RSS feed if I do what I’m supposed to. I published my posts, instead of saving them as private.

    Thanks again :-)

    Posted Feb 18, 2005 at 1:43am | Permalink
  13. Riff

    FYI, Post Levels 1.0 and Batch Categories 0.91 are not compatible when both installed and activated in WordPress v1.5 (final). I installed, activated and tested Post Levels first, and everything was fine. I installed Batch Categories next, and upon activation I got several PHP errors at the top of the Manage Plugins page itself, as well as every other page (have removed full path info from errors):


    Warning: Cannot modify header information - headers already sent by (output started at /home/.[...]/wp-content/plugins/batch-access.php:11) in /home/.[...]/wp-admin/admin.php on line 6

    Warning: Cannot modify header information - headers already sent by (output started at /home/.[...]/wp-content/plugins/batch-access.php:11) in /home/.[...]/wp-admin/admin.php on line 7

    Warning: Cannot modify header information - headers already sent by (output started at /home/.[...]/wp-content/plugins/batch-access.php:11) in /home/.[...]/wp-admin/admin.php on line 8

    Warning: Cannot modify header information - headers already sent by (output started at /home/.[...]/wp-content/plugins/batch-access.php:11) in /home/.[...]/wp-admin/admin.php on line 9

    Errors stopped as soon as I deactivated Batch Categories and refreshed the page.

    Would be extremely nice if you and the Batch Categories author could collaborate on a fix so both plugins will co-exist on one WP installation. Thanks!

    Posted Feb 18, 2005 at 5:42pm | Permalink
  14. What you’re describing is an issue with the Batch Categories plugin. You need to contact the author, there’s nothing I can do about the error you’re seeing (try using Batch Categories without Post Levels, and you’ll see the same error).

    Posted Feb 19, 2005 at 10:51am | Permalink
  15. Sine

    Back again :) Ok I did what you suggested and it now longer shows the php code however now it bring this error up :(

    Warning: Cannot modify header information - headers already sent by (output started at /home/omiogazz/public_html/wp-content/plugins/post-levels.php:77) in /home/omiogazz/public_html/wp-admin/admin.php on line 6

    Warning: Cannot modify header information - headers already sent by (output started at /home/omiogazz/public_html/wp-content/plugins/post-levels.php:77) in /home/omiogazz/public_html/wp-admin/admin.php on line 7

    Warning: Cannot modify header information - headers already sent by (output started at /home/omiogazz/public_html/wp-content/plugins/post-levels.php:77) in /home/omiogazz/public_html/wp-admin/admin.php on line 8

    Warning: Cannot modify header information - headers already sent by (output started at /home/omiogazz/public_html/wp-content/plugins/post-levels.php:77) in /home/omiogazz/public_html/wp-admin/admin.php on line 9

    Posted Feb 19, 2005 at 8:49pm | Permalink
  16. Sine

    aha worked it out !! Just had to remove spaces from the end of the php code

    Posted Feb 19, 2005 at 8:51pm | Permalink
  17. Sine

    Ok now its all installed but it shows the post even when I havethe level set high :( Wsa there another step I missed?

    Posted Feb 20, 2005 at 12:27am | Permalink
  18. You have to make sure you’ve set the post status to Private (not Published).

    Posted Feb 20, 2005 at 10:37am | Permalink
  19. Carla

    Is there any way to make the user level option a little more friendly? I used a hack that had a drop down menu to establish the user level. Thanks. :)

    Posted Feb 21, 2005 at 9:41pm | Permalink
  20. Shelby

    where do I add the

    (private)

    Posted Feb 22, 2005 at 12:34pm | Permalink
  21. Shelby

    nut i meant the PHP code for it…

    Posted Feb 22, 2005 at 12:34pm | Permalink
  22. Carla: The next version of the plugin will have a friendlier UI.

    Shelby: You can add the sample PHP code anywhere within the loop. I’ve added mine next to the post title.

    Posted Feb 22, 2005 at 12:40pm | Permalink
  23. Shelby

    Nevermind I got it.. .sorry about that

    Posted Feb 22, 2005 at 12:41pm | Permalink
  24. giles

    is it possible that even though the post is private it pops up a comment post saying ..
    [normal post layout]
    this post is private please log in to view it ?
    [end]

    Posted Mar 5, 2005 at 3:47am | Permalink
  25. Lyanna

    The sample PHP code for (private) works like a charm. What I would really like though, is to be able to display who can read what according to a certain level. What I mean is, that when I set a post to for instance post-level 2, it displays (Only Josh and Cindy can read this) and when I set a level 3, it displays (Only Josh can read this)

    I’ve tried this with the is_post_level ($level) function, but it doesn’t work. What I did is this:

    if (function_exists(’is_post_level($level)’) && is_post_level(’2′)) : ?>
    (Only x and y can read this)

    Where’s the catch?

    Posted Mar 10, 2005 at 2:42am | Permalink
  26. Lyanna: The plug-in isn’t set up to do what I think you’re looking to do, because the plug-in works in such a way that private posts are never retrieved if the user doesn’t have access to the post. This means you can’t currently let the user know that there’s a post they cannot see.

    I’ll add this type of functionality as a request for future versions.

    Posted Mar 10, 2005 at 9:18am | Permalink
  27. crash

    hi fil. i’m glad someone is working on the “private-posts” front.

    quick question: from a glance, it seems that the minimum “private” level for a post is 1. is there a way to make it 0, without breaking everything?

    i want the least private of the private posts to be readable by registered users (user_level 0), without having to give them posting access (user_level 1+).

    Posted Mar 11, 2005 at 5:31pm | Permalink
  28. Daniel Drucker

    In response to #25, the php function “function_exists” takes the NAME of a function only. So, your code should read:

    if (function_exists(’is_post_level’) && is_post_level(’2′))

    Posted Mar 14, 2005 at 5:41pm | Permalink
  29. Ed Hidden

    I have the plugin working fine. I love it. Thanks for putting forth the effort on this.

    Do you know if there is a way to use a post_level of “2″ by default? I’m building a wordpress site that I want the entire thing protected and would love to not have to remember to add a level of 2 to each post. (this will be used for a team that might not be diligent with the details of making sure all the posts are protected.)

    (I have one post not protected that says, “You need to be logged in to see this stuff…”)

    Posted Mar 15, 2005 at 1:55pm | Permalink
  30. musyoka

    perfect for my needs. Thank-you

    Posted Mar 30, 2005 at 6:54am | Permalink
  31. reagan

    This is a great plugin! it seems that if the Post Status defaulted to Private & the Publish button was eliminated this would be foolproof. anyone have a hack for that? thanks!

    Posted Mar 31, 2005 at 9:15pm | Permalink
  32. Love It! Just one thing...

    I noticed that if a post is marked as Private, even when someone is logged in with the sufficient level to see the post, it is excluded from the Counts for the given category. Is this a bug in functionality, or inteded functionality as part of Private posts.

    Additonally, is it possible to display (in red?) PRIVATE POST so those who have permissions to see it know that they are seeing someting special?

    Posted Apr 5, 2005 at 5:30pm | Permalink
  33. Ludwig

    Hey, how can one make the post not private once it’s private - Like publish it

    Posted Apr 21, 2005 at 11:46pm | Permalink
  34. Ludwig: Just set the post’s status to “Publish”

    Posted Apr 24, 2005 at 10:00am | Permalink
  35. Marie

    Great plug-in! I’ve implemented it on my site and it works like a charm!

    Thanks again,
    Marie (aka Cosmo GRRL!)

    Posted May 8, 2005 at 3:46pm | Permalink
  36. washburn

    Hmmm. Perhaps I am one of the dim ones, but i have some questions: 1) How do I “Add a custom field”? and 2) how do I set the value of post_level to between 1 and 10? Also, after enabling the plug-in, I don’t see a place to set post status to private. So 3) how do I set post status? (Should this be a menu option on the “Write” page, or is this also something that I need to change in the code?)

    Thanks for any help.

    Posted May 12, 2005 at 8:18pm | Permalink
  37. washburn

    ok–figured it out. A drop down menu, like Skippy’s User-Level Post plug-in had would be nice.

    Posted May 12, 2005 at 9:19pm | Permalink
  38. Sevenupcan

    Thanks for your hard work on creating this plugin. I’m sure issues like the user interface will easily be solved in the next release. However I have one concerne.

    Because posts on my site use the “custom fields” (metadata) for other information, for example I list key words related to that post using the custom fields. As you can probably figure out when you view the post the “post_view: 1″ gets shown inside the meta data. And is shown on the post. Which is ugly and slightly confusing to those that don’t know what it does.

    Is there a quick way of solving this? I did think perhaps you could hide it using CSS, but there is no way of seperating it from the other metadata elements.

    Thanks again.

    Posted May 18, 2005 at 3:45pm | Permalink
  39. Drew

    I love this plugin! However I was wondering is there any way for a registered user with sufficient level to view my posts on my website to subscribe to my rss feed in a way that those posts are available? Thanks.

    Posted Jun 11, 2005 at 10:27pm | Permalink
  40. tang

    ´ó¼ÒºÃѽ£¬£¬Ð¡µÜµ½Ð©Ò»ÓΣ¬£¬£¬¾õµÃ±¾Õ¾×öµÃ²»´í£¬£¬Áô¸öÑÔ£¬Õ¾³¤Å¬Á¦Å¶£¡

    Posted Jun 15, 2005 at 5:55pm | Permalink

2 Trackbacks/Pingbacks

  1. Posted Apr 25, 2005 at 9:34pm | Permalink

    [...]

    April 25, 2005
    Post Levels - Category: Lyrics
    http://fortes.com/2005/01/22/introducingpostlevels Lovely little plugin for wordpress. Lets you set custom levels for each post, and thus blocking un [...]

  2. Posted Apr 27, 2005 at 1:35am | Permalink

    [...] tag”> Yutakaã?•ã‚“ã?®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã?«ã‚ˆã‚Š detlogã?§ã‚‚紹介ã?•れã?¦ã?„ã?ŸPost Levelsを入れã?¦ã?¿ã?¾ã?—ã?Ÿã€‚ã?“れã?¯æŠ•稿ã?™ã‚‹ãƒ?ストをã?‚らã? [...]