is_site_admin

Determine if user is a site admin.

Description

is_site_admin( (string) $user_login = '' ); 

Plugins should use is_multisite() instead of checking if this function exists to determine if multisite is enabled.

This function must reside in a file included only if is_multisite() due to legacy function_exists() checks to determine if multisite is enabled.

Parameters (1)

0. $user_login — Optional. (string) => ''
Username for the user to check. Default empty.

Usage

  1. if ( !function_exists( 'is_site_admin' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-deprecated.php'; 
  3.  
  4. // Optional. Username for the user to check. Default empty. 
  5. $user_login = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_site_admin($user_login); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-deprecated.php  
  1. function is_site_admin( $user_login = '' ) { 
  2. _deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' ); 
  3.  
  4. if ( empty( $user_login ) ) { 
  5. $user_id = get_current_user_id(); 
  6. if ( !$user_id ) 
  7. return false; 
  8. } else { 
  9. $user = get_user_by( 'login', $user_login ); 
  10. if ( ! $user->exists() ) 
  11. return false; 
  12. $user_id = $user->ID; 
  13.  
  14. return is_super_admin( $user_id );