WordPress   

Hide any user from the list of users in WordPress Dashboard

Replace yourusername with the username you want to hide.

add_action('pre_user_query','hide_user_from_list');
function hide_user_from_list($user_search) {
  global $current_user;
  $username = $current_user->user_login;
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.user_login != 'yourusername'",$user_search->query_where);

}
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us