Ready to get started?Download WordPress


[resolved] Multiple users - only allow them to see their own posts when logged in? (14 posts)

  1. monkeyfight
    Posted 7 years ago #

    Hi. I'm creating a site based on WordPress, not a blog as such but I think I'll be able to use/customise it's functionality to suit my needs really well.

    One of the first things I need to work out how to do is this...

    Say I only have 2 users for a start, user1 and user2, can I change the admin interface so that user1 can only see his own posts and user2 can only see hers?

    Using the default config of WP2.2 that I'm playing with whoever you're logged in as you can see all posts when you click on the 'Manage' - but I'd like to limit that view to the current logged in user if that's possible?

    Hope someone can help.

    Thanks a lot,

  2. moshu
    Posted 7 years ago #

    Get the Role Manager plugin and you will be able to define custome roles.

  3. MichaelH
    Posted 7 years ago #

    I'm not convinced Role Manager will work here if the idea is to just show the posts that user wrote in Manage Posts, and I'm not sure there is a plugin that will do this exactly.

    Some of the plugins that limit access to Categories might be made to work.

    I'm guessing you might need to either write your own plugin, or modify the core code that displays the Manage Posts screen.

  4. moshu
    Posted 7 years ago #

    Maybe I've missed the "what to view" line...
    Is it important what they view or what they can edit?

    For sure, there is such a capability in the RM plugin: "Edit Others Posts".

  5. MichaelH
    Posted 7 years ago #

    Excellent point about the Edit others posts capability, moshu! Guess we'll have to see what monkeyfight says ;)

  6. monkeyfight
    Posted 7 years ago #

    Cheers for the advice guys. Role Manager looks useful and I may end up using on my project anyway now I know it exists, but it didn't limit the view in the 'Manage' tab to just the posts that the logged in user had created.

    I found this though after some more digging, all you need to do is add this into the edit.php file...

    if (!current_user_can('edit_others_posts'))
    $author = $user_ID;

    And it works perfectly, If I log in as user1 I can only see posts I've created as user1!

    I found it here http://wordpress.org/support/topic/96045?replies=4

  7. MichaelH
    Posted 7 years ago #

    Just one question, where in edit.php did you add that code?

    Thanks for the response.

  8. monkeyfight
    Posted 7 years ago #

    To be honest I don't think it matters. But I'm probably very wrong about that :)

    I'm deffinitely no coder so I tried it in a few different places, and it seemed to work just as well wherever I put it.

    As long as it's somewhere between the <?php require_once('admin.php'); at the top of the file and above the <?php include('admin-footer.php');?> at the bottom it looks like it works.

    I ended up putting it just beneath the line of code that says wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');

    Hope that helps!

  9. MichaelH
    Posted 7 years ago #

    monkeyfight--I couldn't get your example to work but this change to wp-admin/edit.php worked better for me:



    if (!current_user_can('edit_others_posts'))
    $thisauthor = '&author=' . $user_ID;
    wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1' . $thisauthor);
  10. nickrita
    Posted 6 years ago #

    Michael, thanks for your code, wich works fine for me (www.ci-jou.de, wordpress 2.2.3)
    But now the list of the current users posts isn't paged anymore. Do you know any solution?


  11. Zoinks! Graphics
    Posted 6 years ago #

    Hi Rita: Does this work for you?

    $thisauthor = '';
    if (!current_user_can('edit_others_posts'))
    	{ $thisauthor = '&author=' . $user_ID; }
    wp('what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby' . $thisauthor);

    (changed the wp call back to "default" with MichaelH's $thisauthor tacked on)

  12. mincus
    Posted 6 years ago #

    If you are still interested, I think that I've created a WordPress plugin that replicates this functionality without having to edit any WordPress files.

    Manage Your Posts Only WordPress Plugin

    Let me know what you think!

  13. microtag
    Posted 6 years ago #

    Hi mincus...
    I've many authors and this plugin is perfect.
    Thanks a lot

  14. Dimox
    Posted 6 years ago #

    Hi, mincus.

    Firstly, thanks a lot for plugin!

    Secondly, can you do the same for the comments page?

Topic Closed

This topic has been closed to new replies.

About this Topic