Currently, WordPress does a great job displaying pages on the Edit Pages admin area for users with the capability edit_others_pages. However, if a user has edit_others_pages and has not yet authored any pages, WordPress defaults to listing all the pages removing edit actions, etc. However, I would like WordPress to display no pages if a person hasn't authored any pages.
I've tried writing some code into pre_get_posts, but it doesn't seem to work.
add_action( 'pre_get_posts', 'wps_admin_exclude_pages' );
function wps_admin_exclude_pages( $query ) {
if( ! is_admin() )
return $query;
global $pagenow, $current_user;
if( 'edit.php' == $pagenow && 'page' == get_query_var( 'post_type' ) && ! current_user_can( 'edit_others_pages' ) )
$query->set( 'post_author', $current_user->ID );
return $query;
}