Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Restrict editing pages by user role? › Reply To: Restrict editing pages by user role?
This code currently blocks pages 3,4,5 fro all roles NOT just the “franchise” role how I allow the administrator and SUPER administrator to see/edit this page also?
Thank you so much!
if (is_blog_admin() && current_user_can(‘franchise’)) {
add_action(‘pre_get_posts’, ‘restrict_posts_list’);
function restrict_posts_list($query) {$suppressing_filters = $query->get(‘suppress_filters’); // Filter suppression on?
if ($suppressing_filters) {
return query;
}if ($query->query[‘post_type’]==’page’) {
$posts_restriction_type = 2; // Prohibit
$posts_list = array(3,4,5); // comma separated list of pages IDs
if ($posts_restriction_type==1) { // Allow
$query->set(‘post__in’, $posts_list);
} else { // Prohibit
$query->set(‘post__not_in’, $posts_list);
}
}return $query;
}
// restrict_posts_list()
}