Change WordPress user roles and capabilities › Forums › How to or FAQ › Blocking page options
Tagged: meta box, post edit, post editing
- This topic has 4 replies, 3 voices, and was last updated 9 years, 9 months ago by Vladimir.
-
AuthorPosts
-
10/01/2015 at 15:46 #1357Sam NilssonParticipant
I’m using User Role Editor Pro together with Customizr Pro. Now I’d like to restrict some options in the Page Editor for some roles. I’d like to disable the options to
– change Page Attributes
– change Layout optionsI have not been able to find this option in the role editor. Is it possible to configure this? Or do I need to do some customizations?
10/01/2015 at 17:06 #1358VladimirKeymasterThere are no such options in URE. These metaboxes are not managed by user capabilities. So you need to add custom code to remove metabox for selected role. Like this for page attributes:
function remove_page_metaboxes() { if (current_user_can('some_role')) { remove_meta_box('pageparentdiv', 'page', 'side'); } } add_action('admin_menu', 'remove_page_metaboxes');
10/01/2015 at 23:38 #1359Sam NilssonParticipantExcellent – thanks!
/Sam
25/02/2015 at 15:01 #1400JoeParticipantThis is precisely what I’d like to do as well. Seems like its something that should be built into URE. I would want pretty much all the meta boxes in post editing or page editing to not be visible to certain roles with the exception of the text editor and the submission meta box perhaps. Do you know how I can go about doing that?
25/02/2015 at 15:44 #1401VladimirKeymasterThanks 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.
-
AuthorPosts
- You must be logged in to reply to this topic.