Created
November 22, 2013 01:04
-
-
Save FriendlyWP/7592929 to your computer and use it in GitHub Desktop.
Hide the master administrator-level account so it can't accidentally be deleted via the admin panel.
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
// HIDE MASTER ADMIN ACCOUNT SO IT CAN'T BE ACCIDENTALLY DELETED | |
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 !== 'MASTER_ADMIN_USERNAME_HERE') { | |
global $wpdb; | |
$user_search->query_where = str_replace('WHERE 1=1', | |
"WHERE 1=1 AND {$wpdb->users}.user_login != 'MASTER_ADMIN_USERNAME_HERE'",$user_search->query_where); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment