How to Hide Other Users' Posts in the Admin Panel of WordPress
The following post is a little outdated, the latest versions of WordPress do this for you. We’re gonna keep this around just in case some folks are using older versions of WordPress, but we recommend upgrading for security purposes and, of course, all the cool new features!!
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.