Show posts by logged in user and admin in the backend dashboard
-
I have users (contributors) who log into my WordPress backend admin to submit their posts. I don’t want users seeing other users’ posts. When a user logs in, he should just see his own posts in the backend admin area; in addition, I want the logged in user to see posts by the admin (user # 1).
This is the working code I have in my functions.php file to display posts written by the logged in user in the backend:
function posts_for_current_author($query) { global $user_level; if($query->is_admin && $user_level < 5) { global $user_ID; $query->set('author', $user_ID); unset($user_ID); } unset($user_level); unset($user_ID); return $query; } add_filter('pre_get_posts', 'posts_for_current_author');
My problem is this code only shows posts written by the logged in user; I want the user also to see posts written by the admin. How do I do it?
Thank you,
Brian
- The topic ‘Show posts by logged in user and admin in the backend dashboard’ is closed to new replies.