• Hi

    I need to be able to hide the Developer role i have created from the admin and shop manager roles who i still want to be able to edit all other users.

    Can you tell me how i achieve this please?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Ben2010uk

    (@ben2010uk)

    Hi

    Can you also hide the Developer role in the user Additional Capabilities and
    Other Roles section in edit user?

    Thanks
    Ben.

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Ben,

    It’s possible to use ‘editable_roles‘ filter for this purpose.

    Thread Starter Ben2010uk

    (@ben2010uk)

    Hi Vladimir

    I have read through the link you gave but do not understand how this works and how I add the developer role to this code to hide it.

    Can you be a bit more specific please?

    Thanks
    Ben.

    Thread Starter Ben2010uk

    (@ben2010uk)

    Hi Vladamir

    I have added this to my child theme functions file but it is not filtering out higher level users as decribed?

    function remove_higher_levels($all_roles) {
        $user = wp_get_current_user();
        $next_level = 'level_' . ($user->user_level + 1);
    
        foreach ( $all_roles as $name => $role ) {
            if (isset($role['capabilities'][$next_level])) {
                unset($all_roles[$name]);
            }
        }
    
        return $all_roles;
    }
    
    add_filter('editable_roles', 'remove_higher_levels');

    Any idea why this is not working?

    Thanks
    Ben

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide User Role from other Users’ is closed to new replies.