Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5067
    usereditor
    Participant

    Is there a way to disable editing user role or other roles from the user page?

    #5068
    Vladimir
    Keymaster

    Try to install this code (theme’s functions.php or Must Use plugin):

    
    add_filter('ure_users_select_primary_role', 'my_users_select_primary_role', 10, 1);
    function my_users_select_primary_role($select) {
    
        $user = wp_get_current_user();
        if (in_array('user-manager', $user->roles)) {
            $select = false;
        }
        
        return $select;
    }
    
    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('user-manager', $user->roles)) {
            $show = false;
        }
    
        return $show;
    }
    

    Replace ‘user-manager’ with your own user role ID.

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