is_network_admin()WP 3.1.0

Checks whether the current page is a page in the admin section "Network Admin" of the multisite. For example /wp-admin/network/. Conditional tag.

Triggers on these pages:

This function is part of the group of functions:

  • is_admin() - any admin page...
  • is_network_admin() - the admin page in the Network Admin section.
  • is_blog_admin() - the admin page in the per-site admin section, and not the network of sites.
  • is_user_admin() - a special user page in the WordPress admin.

Does not determine whether the user is an admin! For this, use capability checks with current_user_can('manage_options').

Works based on the global variable $current_screen.

1 time — 0.000012 sec (very fast) | 50000 times — 0.02 sec (speed of light) | PHP 7.1.2, WP 4.7.3

No Hooks.

Returns

true|false. True if we are on any page within the Network Admin in the WordPress admin.

Usage

if( is_network_admin() ){
	// we are in network administration
}

Examples

1

#1 Add a widget to the dashboard for Site Network Management

This example shows how to add a widget to the dashboard only if we are in the Site Network Management section:

if ( is_network_admin() ){
	wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
}
0

#2 Check if current screen is network admin screen

if ( is_network_admin() ) {
	echo __( 'You are viewing a WordPress network administration page', 'textdomain' );
} else {
	echo __( 'You are not viewing a WordPress network administration page', 'textdomain' );
}

Notes

  • Global. WP_Screen. $current_screen WordPress current screen object.

Changelog

Since 3.1.0 Introduced.

is_network_admin() code WP 6.9.1

function is_network_admin() {
	if ( isset( $GLOBALS['current_screen'] ) ) {
		return $GLOBALS['current_screen']->in_admin( 'network' );
	} elseif ( defined( 'WP_NETWORK_ADMIN' ) ) {
		return WP_NETWORK_ADMIN;
	}

	return false;
}