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.
November 26th, 2007 at 7:40 pm
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
December 1st, 2007 at 7:11 pm
@fod
thanks for the info! I'm sure it'll help other who need similar functionality on newer versions of WordPress.
March 25th, 2008 at 10:32 pm
okay…i got wp 2.3.3 and i did not find the right file…maybe someone can help me?
March 26th, 2008 at 1:29 am
okay….i got it….sry. for posting ;)
April 8th, 2008 at 5:02 am
This doesn't work on WP2.5 unfortunately… they've changed the query in those files, so any way to update this?
April 8th, 2008 at 5:06 am
Never mind… all that had to be done is removing "$posts = " part in that query line… works with 2.5 now!
April 8th, 2008 at 11:41 am
Thanks for the info James!
June 11th, 2008 at 12:42 am
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.
June 11th, 2008 at 12:43 am
Your site garbled my comment.
Essentially, just put the code:
if ($userdata->user_levelID);
}
On line 14 of edit-post-rows.php
June 11th, 2008 at 12:58 am
thanks ad,
and sorry about the site garbling posts :( Can't get my hands on the problem (either busy or forgetting, or both)
August 3rd, 2008 at 11:06 pm
Any help on this for v2.6. Thanks.
April 3rd, 2009 at 8:53 am
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.
May 12th, 2009 at 5:54 am
How exactly do you do it on WP 2.7.1?
August 7th, 2010 at 7:42 am
Would this work with the latest edition?
August 9th, 2010 at 8:01 am
most probably it won't work with 3.x releases… A lot have changed.