Hide one admin from another admin

How can I hide one admin from another in the users list?
I want to give admin permission to another person without giving him the ability to see/edit my details.

Related posts

Leave a Reply

2 comments

  1. add_action('pre_user_query','yoursite_pre_user_query');
    function yoursite_pre_user_query($user_search) {
      global $current_user;
      $username = $current_user->user_login;
    
      if ($username == '<USERNAME OF OTHER ADMIN>') { 
        global $wpdb;
        $user_search->query_where = str_replace('WHERE 1=1',
          "WHERE 1=1 AND {$wpdb->users}.user_login != '<YOUR USERNAME>'",$user_search->query_where);
      }
    }
    

    Replace text with the actual usernames of the users involved. You can also modify this to hide one admin from all other users (except him/herself), or based on user IDs or roles. For WordPress 3.1+.

  2. My favorite method for this is to use the “User Role Editor” plugin – http://wordpress.org/extend/plugins/user-role-editor/

    The plugin allows you to add more abilities to user roles, or create new user roles based on default WordPress roles.

    For example, if you do not really use the WordPress user role of Editor, you can give another person the role of Editor, then go into the “User Role Editor” and assign them all of the Admin capabilities, however, they will not be able to see you as a user to edit, because your role is higher than theirs.

    If you also use the Editor role, you can create a new role based off the default Editor role, then give it additional capabilities and they still won’t be able to see you as a user to edit because your role is higher than theirs.

    To me, this is the most easy to use of all the user role editing plugins, plus the developer always replies to questions and recommendations.