is_network_admin()WP 3.1.0

Whether the current request is for the network administrative interface.

e.g. /wp-admin/network/

Does not check if the user is an administrator; use current_user_can() for checking roles and capabilities.

Does not check if the site is a Multisite network; use is_multisite() for checking if Multisite is enabled.

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.

Return

true|false. True if inside WordPress network administration pages.

Usage

is_network_admin();

Examples

0

#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.4.3

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;
}