If you open the register function, or you have a lot of other contributors, authors, they will see all the posts published or pending, what a mess! How to find their own posts to edit? I just want to limit the post owners only view and manage their own posts in WordPress dashboard.
add the following php code in your theme’s functions.php file.
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'edit_others_posts' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
This php code allows editors and administrators will be able to see all posts, other users with other roles like contributors or authors will only see their own posts.