Dashboard Widgets for Multisite
Add Custom Dashboard Widgets for a Network
As easy as it could be 👍 If you have experience with non-multisite dashboard widgets, you already know about wp_dashboard_setup
action hook. WordPress Multisite Dashboard action hook is wp_network_dashboard_setup
.
Now let’s try it for a test widget.
Some notes by the below code:
- You can also use
add_meta_box()
function instead ofwp_add_dashboard_widget
, becauseadd_meta_box()
allows to manipulate with dashboard widgets positioning and priority. - 3rd parameter of
add_meta_box()
means where to display a widget/metabox.dashboard-network
is Network Dashboard (line 6) - Do not use IDs of the default widgets –
network_dashboard_right_now
anddashboard_primary
.
add_action('wp_network_dashboard_setup', 'misha_multisite_dash_widget'); function misha_multisite_dash_widget(){ wp_add_dashboard_widget( 'misha_1', 'Test Widget', 'misha_test_widget_2'); add_meta_box('misha_2', 'Misha Widget', 'misha_widget_1', 'dashboard-network', 'normal', 'high' ); } function misha_widget_1(){ echo 'Some content for Misha Widget'; } function misha_test_widget_2(){ echo 'Some content for Test Widget'; }
And the result:

Remove default ones
Before coding anything, please look at the screenshot below:

By default WordPress Multisite dashboard has only two default widgets – “Right now” and “WordPress Events and News”. Let’s remove both of them.
add_action('admin_init', 'misha_remove_default_ones'); function misha_remove_default_ones(){ // remove Right now remove_meta_box( 'network_dashboard_right_now', 'dashboard-network', 'core' ); // remove WordPress Events and News remove_meta_box( 'dashboard_primary', 'dashboard-network', 'side' ); }
- The interesting thing is that if you remove dashboard widgets with
wp_network_dashboard_setup
, they won’t disappear from Screen Options. Usingadmin_init
hook instead solves this problem. - If some plugins added their custom dashboard widgets and you do not know how to remove them, you can try to find out their IDs with
global $wp_meta_boxes; print_r( $wp_meta_boxes['dashboard-network'] );
. Your browser code inspector can help you with it too. - By the way, you can also manipulate with
$wp_meta_boxes
if you want to sort the widgets the way you need.
Comments — 2
Hi there, are you still developing / supporting your Mailchimp plugin? Thanks
Hi Helen,
Yes, sure.
Comments are closed.