Raymond Morphy
Raymond Morphy

Reputation: 2526

how to hide certain user from drupal user list

i would like to hide a certain user (technical admin with full privileges) from users list. because admin (another admin with less privileges) wont delete this admin from users list. although admin can remove another users from site. how to do this?

Upvotes: 0

Views: 1755

Answers (3)

batMask
batMask

Reputation: 744

You can just alter your view. Goto View > Administration: Users > Edit. Then In the FILTER CRITERIA > Add > User: Roles. In Operator select Is none of and select the role you want to hide(administrator) hit apply and save. Done!

Bonus: Also you can hide this user role from registration from(Add new user) by creating hook_form_alter() in your custom module. Something like this:

/**
 * Implements hook_form_alter().
 */
function MyModule_form_alter(&$form, &$form_state, $form_id) {
    //to get the current user role
    global $user;
    $user_roles = $user->roles;

    //use devel to find the user role, which you wish to hide
    //dsm($form);

    switch ($form_id) {
        case 'user_register_form':
            if (!in_array('administrator', $user_roles)) { // hide this only if the current user role is not administrator
                unset($form['account']['roles']['#options'][3]);
            }
        break;
    }
}

This will hide the administrator role when you creating new user. You should follow the same way to hide this from user edit form as well.

Upvotes: 0

GSP
GSP

Reputation: 569

Use Views to replicate the Users list and set a Filter on "Nid != [hidden user's ID]".

Upvotes: 0

Berdir
Berdir

Reputation: 6891

Try http://drupal.org/project/userprotect.

It is a generic problem that the administer users permission is very problematic and gives too many privileges.

Upvotes: 0

Related Questions