You’re actually very close, it’s just a matter of sorting out the syntax errors. For that, I’m not of much help, mySQL is not something I am strong at. Here is my guess at the correct syntax:
$user_search->query_where = str_replace('WHERE 1=1', "$wpdb->users.ID!=1",$user_search->query_where);
This assumes the one and only administrator’s ID is 1, which may be true for many sites, but you should confirm your site’s specifics. A more robust approach would be to query for all users with admin roles, then implode the resulting IDs into a comma delimited list, say into $admin_ids
, then the WHERE query becomes this;
$user_search->query_where = str_replace('WHERE 1=1', "$wpdb->users.ID NOT IN ($admin_ids)",$user_search->query_where);