DISQUS

DISQUS Hello! fortes.com is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

« Back
Author

Post-Levels WordPress Plugin

Started by Fortes · 11 months ago

The Post-Levels plugin allows you to set a numeric “level” to each of your users, and then author posts that are only visible by users above that level.

35 comments

  • Your plugin is absolutely amazing, allowing me to provide a rich, management resource to my member site, and I wanted to thank you for sharing it with us all.

    You have been completely forthcoming and honest about the fact that this plugin was developed a while ago, and "is currently broken for many people using versions of WordPress 2.3 and above." Frankly, with the level of functionality I've experienced thus far I'd hardly say it is broken... just made for an earlier version of WordPress. I am using WordPress 2.5.1 and all but one feature are working exactly as intended. The one feature that isn't is the POST PREVIEW drop down list under the POST LEVELS CONFIGURATION menu. It is weird... the drop down list displays the options properly, which include these 4 choices; none, title only, title plus excerpt, and teaser, until you choose one and hit UPDATE POST LEVELS. Once you do that and go to the "options saved" page, the drop down lists displays a single option that reads, "none for posts to be completely hidden from people who aren't logged in." And, the result for my "logged in" users is that those with the proper levels attached to them see the posts, while those who have lower level settings than the post was assigned, don't.

    I'd be happy to donate to your cause, or pay you to help me troubleshoot this issue, because having the ability to let my junior members see what they are missing will effectively boost sales in membership upgrades. Well, worth the $$. Possible?

    Barbara
  • Silly question, but if I set someone's level as 2, they can then read posts at levels 1 and 2, right?
  • Yes, leica, I've tested it, and that is exactly how it works. If the user is at level 6, for example, they can see 0, 1, 2, 3, 4, 5, and 6.
  • I'm using wordpress 2.5 and this appears to somwhat work...

    On the home page and archive pages the post shows up, title and description, even though i shouldn't have access to it. If I click to go directly to the post I get the "Sorry, no posts matched your criteria" message as expected.

    The problem is this post shouldn't show up on any page but it is. I've disabled all plugins except for this one and also changed the theme back to the wordpress default with the same result.

    In this instance the user level is a 5 and the post level is a 6. I tried with the user as a subscriber and also as a publisher.

    Thoughts??
  • One thing I forgot to mention from the last post...

    In Manage/Posts I do not see this post so that appears to work as well.
  • I just found that if I change the user level to a 1, post is 5 or 6, it works as expected but any other level than a 1 shows the post.
  • Carl,

    I found the same thing, and incorporated this work-around. Instead of my blog home page displaying the Most Recen postst, I added this line to the home.php page under my theme directory

    <?php query_posts('category_name=main&showposts=10');?>

    just below the line that identified the middle "body" section of my page was to begin. For my theme that line reads:

    <div id="contentmiddle">

    What that does is show the Main Category posts on the home page without disturbing any other WordPress features. I chose Main just because, for me, that seemed like the most logical place to put the posts for all viewers to see. You can make it ANY category you have set up, just change the code above and replace the word main with the "slug" name assigned to your category. You can also set the number of posts that will show on that page. You see above, mine says 10. Of course, the key is to then check off the Category you decided on when creating a new post, for all of the posts you want to be available to the public.

    Then, I put a Widget showing the Most Recent list and the Category list in the sidebar, and depending on the user level you set, they will only see the posts in Most Recent that they have access to. Same for the Category list. When they click on one of them, they will only see the posts they have access to under that Category. Not perfect, but definitely viable.

    For me, though, I really want to have all the posts show on the main page, or anywhere. Just the title, though, so my user's can see what they are missing and upgrade their membership to gain access to them. That is what my post above addresses. In the meantime, this works.

    Barbara
  • Fortes... Could you spare a moment and take a look at my question above in a post that begins...

    "Your plugin is absolutely amazing..."

    Would genuinely appreciate a reply. Thanks
  • Hi,

    Like Barbara said, absolutely amazing plugin. Im also willing to donate for an update of this plugin, although Im on the poor side, all I can donate is $40 USD. I would really like the author of the plugin to be the one that fiddles with it, since you know it very well.

    Thanks again for the plugin.
  • Hey All,

    Apologies, but I've been quite busy. WordPress has gone through some major code changes, which is why the Post Levels plugin has had problems lately. I'll see if I can spare some time this weekend to get it working on WP 2.6.
  • That would be just great! Am looking forward to it, and am here to support you in any way you think is helpful.
  • Hello! Add me to the list of people who are desperately hoping for an update to PostLevels that is compatible with the latest version of WP. This is a great plugin, but it only half-works in WP 2.3.1 and doesn't work at all in WP 2.6 (which I'd really love to upgrade to). I can't find anything else like it available, so I really hope you'll have time to update the plugin soon. Thank you for all your work on this so far!
  • I really like this plugin and would love to see a working version for 2.6 and later. I'm familiar with PHP and MySQL and once I learn how to write plugins for WordPress, I'd be happy to help support you in keeping it current.

    Great job on the original code and thank you!
  • I've been using this plugin for a while now and refuse to upgrade WP because it doesn't work in newer versions. Please fix this for 2.6. If you do, I'll be glad to donate money!!
  • Oh and also, I'm glad that you're working on this plugin again! =) I think you stopped supporting this plugin for a while and I was desperately looking for a similar plugin so I can upgrade but never found one.
  • Hello.. me again. I actually upgraded to 2.6.1 and Post Levels seems to work perfectly right now!
  • Hello Katy,
    hello all,

    How did you make Post Levels work in wordpress 2.6.1?

    In my case the following applies to a "private" post regarding its visibility:
    - posts are NOT shown to an user if user level "0" assigned
    - posts ARE shown to any user if its user level is > "0"
    No further options.

    So users with user level "2" can read posts marked "7" :o(

    Awaiting desperately the next post level update :o)
  • I antto change posts enmass and wondered if this could be done via sql. Is the post level stored in a table and if so what is the column name. Ive had a look via phpmyadmin and dont seem to be able to find refernce to levels
  • You'll find what you're looking for using this SQL query:

    SELET * FROM prefix_postmeta WHERE meta_key LIKE 'post_level';

    Replace "prefix_" with your table prefix.
  • Hello,
    The bug I have is when I set a post level I can't schedule the post to publish on a future date.
    Instead it publishes immediately and this causes me to manually publish member-only type content daily. Since I can't schedule post-leveled content this sorta ruins my chances of real vacation :)
  • I have some additional info on this quirk:
    If I write a post and then schedule it for public and publish (now reads 'scheduled') and THEN set the post level it doesn't function properly. The post gets the level tag but remains public and readable by all.
    If I write a post and then set the post level, schedule and "make private" and then publish it publishes "right now"
  • I'm very sorry about the post spam.
    I wanted to clarify more: If I set a post to "make this post private" and set any postlevel at all the post publishes when saved, regardless of whether it is scheduled or not or if I hit the publish button.
    That should sum it all up then...

    Truly a great plugin, thank you...
  • Found the bug tracker for this issue, definitely a Wordpress issue... currently targetted for 2.8

    http://trac.wordpress.org/ticket/5608
  • Well Post Levels just started working on its own in 2.6.1 .. but there are a lot of bugs with it.
    For example, it causes WP Stats not to work, it conflicts with WP Page-Navi plugin and it makes my 'Recent Posts' lists double link each entry....
  • Hi, All,

    I made the following change to the plugin and it works for me with Wordpress 2.6 and 2.6.2.

    219a220
    >
    229c230
    < $sql = preg_replace("/({$wpdb->posts}\.)?post_status[\s]*=[\s]*[\'|\"]publish[\'|\"]/", " ({$wpdb->posts}.post_status = 'publish' OR ({$wpdb->posts}.post_status = 'private' AND (pl_{$wpdb->postmeta}.meta_key = '$postlevels_post_key' AND pl_{$wpdb->postmeta}.meta_value <= $postlevels_current_user_level )))", $sql);
    ---
    > $sql = preg_replace("/OR ({$wpdb->posts}\.)?post_status[\s]*=[\s]*[\'|\"]private[\'|\"]/", " OR ({$wpdb->posts}.post_status = 'private' AND (pl_{$wpdb->postmeta}.meta_key = '$postlevels_post_key' AND pl_{$wpdb->postmeta}.meta_value <= $postlevels_current_user_level ))", $sql);
  • I looked at what your fix did and I incorporated in to my code with a small modification. Thanks!

    I changed your code from:

    $sql = preg_replace("/OR ({$wpdb->posts}\.)?post_status[\s]*=[\s]*[\'|\"]private[\'|\"]/", " OR ({$wpdb->posts}.post_status = 'private' ... etc

    to

    $sql = preg_replace("/({$wpdb->posts}\.)?post_status[\s]*=[\s]*[\'|\"]private[\'|\"]/", " ({$wpdb->posts}.post_status = 'private' ... etc

    I discovered that the inclusion of the OR causes a problem with searching for content on the blog because (and this may be a bug in Wordpress 2.6.1 code) there is a difference in the base SQL query (prior to the query change that PostLevels does) that says "look for public & private posts" when you're not searching... but when you do a search it says "look for public posts, and private posts that match your user ID"...

    Btw, that query is dependent upon a function call to function postlevels_query_match... so you should update the match value since you changed the string in the preg_replace function call.

    // Tells us whether or not we should edit the query
    function postlevels_query_match($sql)
    {
    global $wpdb;
    //return ((preg_match("/post_status[\s]*=[\s]*[\'|\"]publish[\'|\"]/", $sql)) && (preg_match("/[\s|,]{$wpdb->posts}[\s|,]/", $sql)));
    return ((preg_match("/post_status[\s]*=[\s]*[\'|\"]private[\'|\"]/", $sql)) && (preg_match("/[\s|,]{$wpdb->posts}[\s|,]/", $sql)));
    }



    Additionally this entire function is "broken" if you consider searching for posts. I'm making a note of some odd query structure I'm seeing from Wordpress 2.6.1... after I upgrade to 2.7 (whatever the latest code is) I may need to file a bug report with the wordpress dev team to clean up their SQL query structure. Or, they may have fixed the problem I see in 2.7... either way, additional code will need to be added to deal with the fact that users at a certain level should be able to see private posts by other users if the post_level is lower than their user_level.
  • So we are at wordpress 2.6.3 and it's still not working. Fortes said he will do something... that was 3 months ago.
  • I have 2.6.3 and it works just fine. I have a weird little issue with using a post prefix and it showing up on my "pages" on the index page but no other pages (and they aren't "private" pages), but I can live with that since it is aesthetic rather than functional and doesn't detract from the whole.
  • I have 2.6.3 and it works just fine. I have a weird little issue with using a post prefix and it showing up on my "pages" on the index page but no other pages (and they aren't "private" pages), but I can live with that since it is aesthetic rather than functional and doesn't detract from the whole.
  • Bishop, I found and squashed the bug you're experiencing with the post prefix/suffix showing up:

    (spaces get stripped from the code sample below in display, but they're there.)

    function postlevels_the_title($title, $incomingpost = null)
    {
    if( is_object($incomingpost) )
    {
    if( $incomingpost->post_status == 'private' )
    {
    $title = str_replace("Private: ", "", $title);
    return get_option('postlevels_private_before_title') . $title . get_option('postlevels_private_after_title') . $pldebug;
    }
    else
    {
    return $title;
    }
    }
    else
    {
    $iPos = strpos( $title, "Private: " );
    if( $iPos === false )
    {
    return $title;
    }
    else
    {
    $title = str_replace("Private: ", "", $title);
    return get_option('postlevels_private_before_title') . $title . get_option('postlevels_private_after_title');
    }
    }
    }

    If Felipe decides to continue development, I'll be happy to work with him, but if not, I'll be going it alone.

    I opened a bugtracker to the public to help track bugs. The explanation for this bug, why it happened, and the fix can be found there. Once I've done extensive testing on my revision, I'll release it under a different plugin name (similar, but still different) and keep it current. I need this plugin for my own site and Felipe unfortunately hasn't updated it in over a year, and hasn't responded to this thread in 4 months. (No doubt he's busy working on other things, no disrespect intended to him. He did an awesome job getting the plugin working in the first place as I said above.)

    http://www.datarave.net/bt/bug_view_advanced_pa...

    You will need to register an account to view the bugtracker.
  • I'll no longer be responding to comments in this thread... although I will be monitoring this thread for a while in case Fortes would like to collaborate on this project going forward.

    I started my own DISQUS thread for this topic, and I intend to release my own version sometime this month (maybe not through Wordpress Extend, but at least through my own blog.)

    http://datarave.disqus.com/post_levels_2_workin...
  • v0.10.0 Beta, the first public release is now available on my website:
    http://www.datarave.net/zfh/2008/12/23/post-lev...

    This version has been tested with Wordpress 2.6.1 and 2.7.
  • Shouldn't a non-registered user still be able to see the private post (for example, the title & excerpt if that was set in the settings) even if they aren't logged in?

    I tried logging out and can't see the post at all... whereas in my older WP installation, I'm still able to see the title and excerpt.
  • Response:
    http://datarave.disqus.com/post_levels_2_workin...

    As I said above, I'm no longer responding in this thread. In another couple of weeks, I won't even provide a courtesy redirect.
  • Oops sorry I had multiple tabs opened, I think I posted in the wrong thread!

Add New Comment

Returning? Login