Make WordPress Core


Ignore:
Timestamp:
01/06/2010 11:27:22 PM (15 years ago)
Author:
ryan
Message:

Introduce is_super_admin(). see #11644.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r12597 r12611  
    10631063}
    10641064
     1065/**
     1066 * Determine if user is a site admin.
     1067 *
     1068 * @since 3.0
     1069 *
     1070 * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
     1071 * @return bool True if the user is a site admin.
     1072 */
     1073function is_super_admin( $user_id = false ) {
     1074    global $current_user;
     1075
     1076    if ( !$current_user && !$user_id )
     1077        return false;
     1078
     1079    if ( !$user_id )
     1080        $user_id = $current_user->id;
     1081
     1082    if ( !$user_id )
     1083        return false;
     1084
     1085    $user = new WP_User($user_id);
     1086
     1087    $site_admins = get_site_option( 'site_admins', array('admin') );
     1088    if ( is_array( $site_admins ) && in_array( $user->user_login, $site_admins ) )
     1089        return true;
     1090
     1091    return false;
     1092}
     1093
    10651094?>
Note: See TracChangeset for help on using the changeset viewer.