Remove admin AND editor from the “change role to” menu in user listing

Try using below code to remove administrator and editor option from drop down. Use
editable_roles filter

function wdm_user_role_dropdown($all_roles) {

    global $pagenow;

    if( current_user_can('editor') && $pagenow == 'user-edit.php' ) {
        // if current user is editor AND current page is edit user page
        unset($all_roles['administrator']);
        unset($all_roles['editor']);
    }

    return $all_roles;
}
add_filter('editable_roles','wdm_user_role_dropdown');

Leave a Comment