WordPress Function to Remove Admin (User #1) from User list

Remove Admin (User #1) from User list

function your_pre_user_query($user_search) {
  $user = wp_get_current_user();
  if ($user->ID!=1) {
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.ID<>1",$user_search->query_where);
  }
}
add_action('pre_user_query','your_pre_user_query');

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *