Admin Notices provide a an easy to use tool for plugin and theme developers to show messages and warnings in the WordPress Dashboard. The admin_notices hook is what we use to display our messages, however, this hook will only display messages in the regular Dashboard and not the Network Admin dashboard for multi site installs. Luckily, there is another hook that lets us show our notices in the Network Admin.

Just like with the regular admin notices, we setup a simple function that outputs the HTML of our notice:

1
2
3
function pippin_admin_notice() {
	echo '<div class="updated"><p>This notice is displayed in the admin.</p></div>';
}

Now, if we were trying to display this message in the regular WordPress Dashboard, we would do this:

1
add_action('admin_notices', 'pippin_admin_notice');

But, as mentioned above, this will not show anything in the Network Admin of a multisite install. If we want to do that, we need to use this hook instead:

1
add_action('network_admin_notices', 'pippin_admin_notice');

If we want to display a notice across the Network Admin and the individual site dashboards, we can combine the two:

1
2
3
4
5
function pippin_admin_notice() {
	echo '<div class="updated"><p>This notice is displayed across the entire network.</p></div>';
}
add_action('admin_notices', 'pippin_admin_notice');
add_action('network_admin_notices', 'pippin_admin_notice');