FriendlyWP
11/22/2013 - 1:04 AM

Hide the master administrator-level account so it can't accidentally be deleted via the admin panel.

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);
  }
}