W3cubDocs

/WordPress

is_super_admin( int $user_id = false )

Determine if user is a site admin.

Parameters

$user_id

(int) (Optional) (Optional) The ID of a user. Defaults to the current user.

Default value: false

Return

(bool) True if the user is a site admin.

Source

File: wp-includes/capabilities.php

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

	return false;
}

Changelog

Version Description
3.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_super_admin