is_super_admin() WordPress Function
The is_super_admin() function in WordPress checks if the current user is a super administrator. This function is only available for multisite installations. Super administrators have all the capabilities of a normal administrator, plus they can manage networks and perform site-wide actions.
is_super_admin( int|false $user_id = false ) #
Determines whether user is a site admin.
Parameters
- $user_id
(int|false)(Optional) The ID of a user. Defaults to false, to check the current user.
Default value: false
Return
(bool) Whether the user is a site admin.
Source
File: wp-includes/capabilities.php
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; } } else { if ( $user->has_cap( 'delete_users' ) ) { return true; } } return false; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |