Using WordPress ‘network_admin_notices’ PHP action

The network_admin_notices WordPress action displays notices on the network admin screen.

Usage

add_action('network_admin_notices', 'your_custom_function');
function your_custom_function() {
// your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: network_admin_notices

Examples

Display a simple notice

Show a basic notice on the network admin screen.

add_action('network_admin_notices', 'display_simple_notice');
function display_simple_notice() {
echo '<div class="notice notice-info"><p>Your notice message.</p></div>';
}

Show a warning notice

Display a warning notice on the network admin screen.

add_action('network_admin_notices', 'display_warning_notice');
function display_warning_notice() {
echo '<div class="notice notice-warning"><p>Warning: Please check your settings.</p></div>';
}

Display an error notice

Show an error notice on the network admin screen.

add_action('network_admin_notices', 'display_error_notice');
function display_error_notice() {
echo '<div class="notice notice-error"><p>Error: An issue has occurred.</p></div>';
}

Show a success notice

Display a success notice on the network admin screen.

add_action('network_admin_notices', 'display_success_notice');
function display_success_notice() {
echo '<div class="notice notice-success"><p>Success: Your changes have been saved.</p></div>';
}

Show a custom notice with a link on the network admin screen.

add_action('network_admin_notices', 'display_custom_notice_with_link');
function display_custom_notice_with_link() {
echo '<div class="notice notice-info"><p>For more information, visit <a href="https://example.com" target="_blank">example.com</a>.</p></div>';
}