Skip to content

Instantly share code, notes, and snippets.

@FriendlyWP
Created November 22, 2013 01:04
Show Gist options
  • Save FriendlyWP/7592929 to your computer and use it in GitHub Desktop.
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.
// 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