Support » Plugin: User Role Editor » How to hide “Other roles” field from users form?

  • Resolved rogeriodec

    (@rogeriodec)


    How to hide (or disable) the “Other Roles” dropdown field which was inserted by this plugin at the end of the add new user form (/wp-admin/user-new.php)?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Vladimir Garagulia

    (@shinephp)

    Use this code:

    
    add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section');
    add_filter('ure_bulk_grant_roles',  'ure_show_additional_capabilities_section');
    
     
    function ure_show_additional_capabilities_section($show) {
    
        $user = wp_get_current_user();
        if (in_array('role_id', $user->roles)) {
            $show = false;
        }
    
        return $show;
    }
    

    Replace role_id with ID of role for which you wish to hide “Other roles” section.

    How to know to role_ID?

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Role ID is shown at the User Role Editor (Users->User Role Editor) at the role selection drop-down list, to the right from the role name.

    If you wish to make this for all roles including ‘administrator’ you may leave just a single line:

    
    function ure_show_additional_capabilities_section($show) {
      return false;
    }
    

    So, is the role ID a string (between parenthesis)?

    Yes, it’s a string, like “contributor”.
    Thanks, it solved.

    • This reply was modified 11 months, 2 weeks ago by rogeriodec.
    Plugin Author Vladimir Garagulia

    (@shinephp)

    Right, if you see “Some Role Name (some_role_id)” then role ID is :
    some_role_id

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to hide “Other roles” field from users form?’ is closed to new replies.