WordPress: how to hide other users' posts in admin panel

I am working on another WordPress-based system currently, and have faced a problem when I have many users who can log into WordPress admin panel to post their blog entries. But doing so, they all can see each others posts, even though not being able to edit any post but their own's.

From users  point of view, it is not the best thing in the world to look for your own posts in the list, especially if there are lots of users in the system.

So, here's a simple solution for the problem – after logging into the system, non-admin users will be able to only see their own posts in the Admin -> Manage panel. The only thing is that I seems no plugin solultion is possible so you have to add 3 lines to one file.

The file you have to add these lines is located in /wp-admin/edit.php file in your WordPress installation. You have to go to line 150 (or near it, where it says:

if ($posts) {
$bgcolor = '';
foreach ($posts as $post)…..

..etc

Now, just add the following code ABOVE the one mentioned above:

if ($userdata->user_level<10) {
    $posts = query_posts("author=".$userdata->ID);
}

So, in the end you will get something like that:

<?php

if ($userdata->user_level<10) {
    $posts = query_posts("author=".$userdata->ID);
}

if ($posts) {
$bgcolor = '';
foreach ($posts as $post) { start_wp();
$class = ('alternate' == $class) ? '' : 'alternate';

You're done! Now all non-admin users will see only their own posts :) Simple and easy. Have fun. 

15 Responses to “WordPress: how to hide other users' posts in admin panel”

  1. fod Says:

    just what i needed, thank you! had to change edit-post-rows.php because i have wp 2.3.0, other than that it's all good

  2. mike Says:

    @fod

    thanks for the info! I'm sure it'll help other who need similar functionality on newer versions of WordPress.

  3. toul Says:

    okay…i got wp 2.3.3 and i did not find the right file…maybe someone can help me?

  4. toul Says:

    okay….i got it….sry. for posting ;)

  5. James Says:

    This doesn't work on WP2.5 unfortunately… they've changed the query in those files, so any way to update this?

  6. James Says:

    Never mind… all that had to be done is removing "$posts = " part in that query line… works with 2.5 now!

  7. mike Says:

    Thanks for the info James!

  8. ad Says:

    In v2.3.3 you need to edit edit-post-rows.php and go to line 14, and…

    BENEATH where it says;

    and ABOVE where it says;

    <?php
    if ( have_posts() ) {

    Put the line;


    if ($userdata->user_levelID);
    }

    So, altogether you should have;

    user_levelID);
    }

    if ( have_posts() ) {

    I found this to work on v2.3.3 but not sure about later releases.

  9. ad Says:

    Your site garbled my comment.

    Essentially, just put the code:


    if ($userdata->user_levelID);
    }

    On line 14 of edit-post-rows.php

  10. mike Says:

    thanks ad,

    and sorry about the site garbling posts :( Can't get my hands on the problem (either busy or forgetting, or both)

  11. Shyam Gupta Says:

    Any help on this for v2.6. Thanks.

  12. REUS Says:

    Hi:

    I use WP v2.7.1 and i paste the code in line 177 before:

    Works!!!!

    Really thanks.

    Anybody apply this in the edit-comments.php ????

    Thanks again.

  13. Maki Says:

    How exactly do you do it on WP 2.7.1?

  14. Eliza Says:

    Would this work with the latest edition?

  15. mike Says:

    most probably it won't work with 3.x releases… A lot have changed.

Leave a Reply