The is_network_admin() WordPress PHP function determines whether the current request is for the network administrative interface.
Usage
if (is_network_admin()) { // Do something if the current request is for the network admin interface } else { // Do something else if the current request is not for the network admin interface }
Parameters
- None
More information
See WordPress Developer Resources: is_network_admin()
- This function does not check if the user is an administrator. Use current_user_can() for checking roles and capabilities.
- This function does not check if the site is a Multisite network. Use is_multisite() for checking if Multisite is enabled.
Examples
Display a message if on a network admin page
This example displays a message if the user is viewing a network administration page.
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'); }
Enqueue a script only for network admin pages
This example enqueues a script only if the user is viewing a network administration page.
function my_enqueue_scripts() { if (is_network_admin()) { wp_enqueue_script('my-network-admin-script', get_template_directory_uri() . '/js/my-network-admin-script.js'); } } add_action('admin_enqueue_scripts', 'my_enqueue_scripts');
Redirect non-network admin users
This example redirects non-network admin users to the main dashboard page.
function my_redirect_non_network_admin() { if (!is_network_admin()) { wp_redirect(admin_url()); exit; } } add_action('admin_init', 'my_redirect_non_network_admin');
Add a network admin menu item
This example adds a new menu item to the network admin dashboard.
function my_add_network_admin_menu() { if (is_network_admin()) { add_menu_page('My Network Page', 'My Network Page', 'manage_network', 'my-network-page', 'my_network_page_callback'); } } add_action('admin_menu', 'my_add_network_admin_menu'); function my_network_page_callback() { echo '<h1>' . __('My Network Page', 'textdomain') . '</h1>'; }
Modify the admin footer text for network admin pages
This example modifies the admin footer text specifically for network administration pages.
function my_network_admin_footer_text($footer_text) { if (is_network_admin()) { $footer_text = __('Thank you for using my custom network admin theme!', 'textdomain'); } return $footer_text; } add_filter('admin_footer_text', 'my_network_admin_footer_text');