wpseek.com
A WordPress-centric search engine for devs and theme authors



is_super_admin › WordPress Function

Since3.0.0
Deprecatedn/a
is_super_admin ( $user_id = false )
Parameters:
  • (int|false) $user_id Optional. The ID of a user. Defaults to false, to check the current user.
    Required: No
    Default: false
Returns:
  • (bool) Whether the user is a site admin.
Defined at:
Codex:

Determines whether user is a site admin.



Source

function is_super_admin( $user_id = false ) {
	if ( ! $user_id ) {
		$user = wp_get_current_user();
	} else {
		$user = get_userdata( $user_id );
	}

	if ( ! $user || ! $user->exists() ) {
		return false;
	}

	if ( is_multisite() ) {
		$super_admins = get_super_admins();
		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins, true ) ) {
			return true;
		}
	} elseif ( $user->has_cap( 'delete_users' ) ) {
		return true;
	}

	return false;
}