Change WordPress user roles and capabilities › Forums › How to or FAQ › Blocking page options › Reply To: Blocking page options
25/02/2015 at 15:44
#1401
Keymaster
Thanks you for the suggestion. I will add interface for it with high probability. At this moment use this code (it is for the ‘Editor’ role):
add_action('add_meta_boxes', 'remove_post_metaboxes', 11);
function remove_post_metaboxes() {
if (!current_user_can('editor')) {
return;
}
$side_metaboxes = array('formatdiv', 'categorydiv', 'tagsdiv-post_tag', 'postimagediv');
$normal_metaboxes = array('revisionsdiv', 'postexcerpt', 'trackbacksdiv', 'postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv');
foreach($side_metaboxes as $metabox) {
remove_meta_box($metabox, 'post', 'side');
}
foreach($normal_metaboxes as $metabox) {
remove_meta_box($metabox, 'post', 'normal');
}
}
add_action('add_meta_boxes', 'remove_page_metaboxes', 11);
function remove_page_metaboxes() {
if (!current_user_can('editor')) {
return;
}
$side_metaboxes = array('pageparentdiv', 'postimagediv');
$normal_metaboxes = array('postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv');
foreach($side_metaboxes as $metabox) {
remove_meta_box($metabox, 'page', 'side');
}
foreach($normal_metaboxes as $metabox) {
remove_meta_box($metabox, 'page', 'normal');
}
}
You may put it into functions.php file of your active theme or as the separate php file at wp-content/mu-plugins directory. Do not forget to start php file from <?php line.