Answers for "Hide Administrator From User List"

0

Hide Administrator From User List

// Hide admin from user list
 
add_action('pre_user_query','isa_pre_user_query');
function isa_pre_user_query($user_search) {
  $user = wp_get_current_user();
  if ($user->ID!=1) { // Is not administrator, remove administrator
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.ID<>1",$user_search->query_where);
  }
}
Posted by: Guest on August-18-2021

Code answers related to "Hide Administrator From User List"

Browse Popular Code Answers by Language