To get the current role of the user
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$roles = $current_user->roles; //$roles is an array
After getting role set page ids which you want to show according to roles (for example)
if($roles=='administrator'){
$args=array('21','22','23');
}
or
if($roles=='subscriber'){
$args=array('24','25','26');
}
you can use parse_query
filter hook to exclude your pages using post__not_in attribute
add_filter( 'parse_query', 'exclude_pages_from_admin' );
function exclude_pages_from_admin($query) {
global $pagenow,$post_type;
if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
$query->query_vars['post__not_in'] = $args
}
}
Important Links: