Request a Quote
Customer Focused
Web Services

Hide a user account from the Users screen

June 15, 2022
Code Category:

Hide a specific user account from the Dashboard > Users screen in WordPress

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') { 
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.user_login != 'fotan'",$user_search->query_where);
  }
}
Give us a call (541) 784-5711

Start a converstation


©2022 Fotan Web Design