Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7676
    abmex
    Participant

    Sorry, but this seems really complicated and confusing to me.
    I need a user role that is able to promote (upgrade) users, let’s say from Subscriber to Contributor.

    So I’ve created a new role “Manager”, and gave this Manager role the capabilities ‘edit users’, ‘list users’, ‘promote users’.

    Now when I log in as a “Manager”, then try to edit a user, I see not only a field “Role” with the dropdown options of the available user roles, but I also have an additional section on the user profile called “Additional Capabilities” with the 2 fields “Other Roles” and “Capabilities”.

    This is super confusing when the “Manager” can change the user role on 2 different fields within a user profile.

    BTW, the “User Role Editor” in “Custom Capabilities” in the URE settings for the “Manager” doesn’t have a single capability checked/enabled.

    #7678
    Vladimir
    Keymaster

    User Role Editor by default extends WordPress UI to allow grant more than single user role via “Other Roles” field. You can hide it adding this custom code to the active theme functions.php file:

    
    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;
    }
    
    #7679
    abmex
    Participant

    Thanks for trying to help, but this didn’t work.

    This piece of code only removed the Capabilities field with the ‘edit capabilities” link, but the entire section “Additional capabilities” including the dropdown field “Other Roles” is still there.
    https://www.dropbox.com/s/4m3dxb1yikwwvq2/Screen%20Shot%202021-09-05%20at%207.15.25%20AM.png?dl=0

    I only want the “Manager” role I’ve created to be able to change the user role of other users (let’s say from Subscriber to Contributor), but restrict it to a maximum of manager. I don’t want an extra field/section to assign ADDITIONAL roles or capabilities.

    #7680
    abmex
    Participant

    Oh never mind, I found that I need to update the ID of the user role in the code.
    Works now.
    Thanks again.

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