Support » Requests and Feedback » Request: Private posts readable to defined user gr

  • Hi,
    an interesting feature I missed in wordpress is to post private entries, which can be read by logged in users only.
    For example users at level 1 can’t post in the blog, but can read these “hidden” posts.
    McClane

Viewing 8 replies - 1 through 8 (of 8 total)
  • If you search for ‘private’ or ‘draft’, there’s a whole discussion (and my analysis and tweaks of the code) for how to adjust the current wordpress code to your liking.
    Basically, you could make it so that any logged-in user (userlevel >= 1) is able to see private posts — that’s trivial.
    Let me know if you can’t find the thread and need me to re-analyze this specific topic… 😉
    -d
    http://www.chait.net

    Thread Starter Anonymous

    I searched for private and found many posts to the private function, but not especially to my problem.
    I tried myself to edit the queries but I couldn’t fit in the logged in userlvel in the head php.

    even I made the post private, I can still view the post after I log out.

    Thread Starter Anonymous

    I would really like this feature as well. I’m currently using MT, but I am looking for other blog tools that have this feature, but none do. I would try to implement this hack, but I am not familar with PHP at all. Any suggestions?

    Thread Starter Anonymous

    davidchait,
    Thanks for your code. But it doesn’t work (well it works when you see the edit page, but in the normal site, it doesn’t) until you add the following line before your snippet because $user_level and $user_ID are not set when you are viewing the site.
    get_currentuserinfo(); // Refresh user data from session variables.
    Hope it helps.

    Thread Starter Anonymous

    I tried this (w/ WP 1.2), but it doesn’t seem to have any effect. When I run the SQL, it pulls back the private posts, but they are never displayed.
    Any thoughts?
    Thanks,
    Zak

    Thread Starter Anonymous

    oops – i got it! i wanted *anyone* who is logged in to be able to see private posts. i don’t allow registration, so as long as the user is logged in they are OK. My problem is that there is a typo above (“==” instead of “=”).
    Here is the full code I put into wp-blog-header.php:
    // Get private posts
    get_currentuserinfo();
    if (isset($user_ID) && ('' != intval($user_ID)))
    $where .= " OR (post_author = $user_ID AND post_status != 'draft') OR (post_status = 'private'))";
    else
    $where .= ')';

    I’m using WP WP 1.2.1 and this code hack works great except for one minor side affect.
    The categorys… the only categories that show up on the index.php page are ones with public posts, even if I’m logged in. The thing is I do have some categories that have only private posts. Any idea how to get all categories to display when I’m logged in?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Request: Private posts readable to defined user gr’ is closed to new replies.