If the Rol
is in the meta you have to get the IDs of all of them then compare the meta access rol to the rol of the user:
$post_parent_ID = $post->post_parent ? $post->post_parent : $post->ID;
$title = $post->post_parent ? get_the_title( $post->post_parent ) : get_the_title( $post->ID );
//we use get posts to get all posts for the given ID
$children_pages_array = get_posts(array('numberposts' => -1, 'post_status' => 'publish', 'post_type' => 'any', 'post_parent' => $post_parent_ID, 'suppress_filters' => false));
//we get the user rol
$user_role = sb_get_user_role();
//here we create an array that will be populated with IDs
$ID_pages_rol_array = array();
foreach ($children_pages_array as $child_page_obj) {
//we get the rol that can access this page
$page_role = get_post_meta($child_page_obj->ID, '_members_access_role');
//do the current user rol have access to this page?
if ($page_role == $user_role) {
//yes it does add to the IDs of pages that this rol can access
array_push($ID_pages_rol_array, $child_page_obj->ID);
}
}
$children = wp_list_pages(array(
'title_li' => '',
'include' => $ID_pages_rol_array, //lets send those IDs to be formatted as list items
'echo' => 0,
'depth' => 1
));
you can get the IDs with get_posts
(actually the entire post object) after making the array of permitted IDs, that can be send to wp_list_pages
.