I would like to display only authors own posts in dashboard all posts section. As of now it displays everything.
I found some code here which is written by @t31os Its working correctly.
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);
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
But user_level is deprecated. So can anyone modify the code for new version? Thanks
$user_level
is deprecated, you might be able to check for it's role(s) then instead.$user_level
with the appropriate role, see Roles and Capabilities: User Levels which level relates to which role.