You can do this very easily using the edit_posts_per_page
hook or edit_{$post_type}_per_page
hook for pages and custom post types
You can change based on the user role:
function my_edit_post_per_page_role_based( $per_page, $post_type ) {
//admin sees 25 posts per page
if (urrent_user_cancurrent_user_can('administrator')){return 25;}
//editor sees 20 posts per page
elseif(current_user_can('editor')){return 15;}
//author sees 10 posts per page
elseif(current_user_can('author')){return 10;}
//contributor sees 5 posts per page
elseif(current_user_can('contributor')){return 5;}
return $per_page;
}
add_filter( 'edit_posts_per_page', 'my_edit_post_per_page_role_based' );
Or change base on user id:
function my_edit_post_per_page_user_based( $per_page, $post_type ) {
global $current_user;
get_currentuserinfo();
//specific user id ex: user with the ID of 23
if (23 == $current_user->ID){
return 20;
}
//user group
$can_see_only_10 = array(2,5,36,55,47); //array holding the group ids
if (in_array($current_user->ID,$can_see_only_10)){
return 10;
}
return $per_page;
}
add_filter( 'edit_posts_per_page', 'my_edit_post_per_page_user_based' );