WordPress.org

Ready to get started?Download WordPress

Forums

Request: Private posts readable to defined user gr (9 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    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

  2. davidchait
    Member
    Posted 10 years ago #

    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

  3. Anonymous
    Unregistered
    Posted 10 years ago #

    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.

  4. jakeleesf
    Member
    Posted 10 years ago #

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

  5. Anonymous
    Unregistered
    Posted 10 years ago #

    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?

  6. Anonymous
    Unregistered
    Posted 10 years ago #

    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.

  7. Anonymous
    Unregistered
    Posted 9 years ago #

    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

  8. Anonymous
    Unregistered
    Posted 9 years ago #

    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 .= ')';

  9. wassimk
    Member
    Posted 9 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.