is_super_admin()
Determine if user is a site admin.
1 time — 0.000055 sec (very fast) | 50000 times — 0.18 sec (very fast) | PHP 7.1.2, WP 4.7.5
No Hooks.
Return
true|false
. Whether the user is a site admin.
Usage
is_super_admin( $user_id );
- $user_id(int|false)
- The ID of a user.
Default: false, to check the current user
Examples
#1 Check the access level of the current user
If user is the super administrator, display it.
global $user_ID; if( is_super_admin( $user_ID ) ){ echo 'Hello network chief administrator!'; }
#2 Removes the "Edit" menu for not Super Admins
// Removes the "Edit" menu for users who are not Super Admins of a multisite network if ( ! is_super_admin() ) { add_action( 'admin_init', 'wpdocs_remove_edit_menu' ); } /** * Remove the profile editing link for non-super admins. */ function wpdocs_remove_edit_menu() { remove_menu_page('edit.php'); }
#3 Since WP 4.8 is_super_admin is discouraged
// As of WordPress 4.8 the use of is_super_admin is discouraged. // Use the `setup_network` capability check instead. if ( current_user_can( 'setup_network' ) ) { // do something }
Changelog
Since 3.0.0 | Introduced. |