Un motore di ricerca WordPress per sviluppatori e autori di temi



is_super_admin ›

Da3.0.0
Deprecaton/a
is_super_admin ( $user_id = false )
Parametri:
  • (int) $user_id (Optional) The ID of a user. Defaults to the current user.
    Richiesto: No
    Default: false
Ritorna:
  • (bool) True if the user is a site admin.
Definito a:
Codex:

Determine if user is a site admin.



Sorgenti

function is_super_admin( $user_id = false ) {
	if ( ! $user_id || $user_id == get_current_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 ) ) {
			return true;
		}
	} else {
		if ( $user->has_cap( 'delete_users' ) ) {
			return true;
		}
	}

	return false;
}