Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1357
    Sam Nilsson
    Participant

    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 options 

    I 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? 

    #1358
    Vladimir
    Keymaster

    There 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');
    
    #1359
    Sam Nilsson
    Participant

    Excellent – thanks!

    /Sam

    #1400
    Joe
    Participant

    This 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?

    #1401
    Vladimir
    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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.