WordPress Trick: Remove Dashboard Widgets

Want to remove some dashboard widgets programmatically? Perhaps to hide useless cruft from every role but the Administrator? Dump this in your themes functions.php:

function remove_dashboard_widgets() {

	global $wp_meta_boxes;

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

}

if (!current_user_can('manage_options')) {
	add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
}

This removes all dashboard widgets, so you’ll probably want to poke around and comment out some of these array unsets.

Responses to “WordPress Trick: Remove Dashboard Widgets”

  1. Nice! Always wanted to implement this but never actually looked it up.
    thanks.

  2. Lloyd Budd says:

    Wrap this in a plugin and millions will love you ;-)

  3. Micah says:

    Will this speed WP up in any way? Or is it just a visual improvement?

  4. Joen says:

    It’s a visual change only. And it’s useful mostly to unclutter the wordpress interface for novice users.

  5. kamal says:

    huge tips, any one can to turn it to a plugin? :)

  6. WPFuss says:

    Nice tip!… Great for client projects.

  7. Matt Pealing says:

    Great post! Thanks.

    Just one problem, I found that this code didn’t remove the ‘Recent Drafts’ widget and that this code is necessary instead:

    unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_recent_drafts’]);

  8. Linus says:

    Thanks so much! I’m Italian blogger. I use your hack for a Paid to write site, for me is very very important! Best reguards.

  9. Linus says:

    just a problem, I’m using W3 total cache plugin, how can i remove its updates from dashboard? (i don’t know the variables…)
    thanks in advance. Best reguards.

  10. Linus says:

    Found answers! For removing the W3 total cache updates from dashboard, add these strings:

    unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘w3tc_latest’]);
    unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘w3tc_pagespeed’]);

  11. shamiao says:

    This code contains a fatal error on current_user_can function. Theme functions.php or plugin files are loaded BEFORE the wordpress initial functions defined. All the code should be included into a hook function and wait to be called by wordpress.

    And on the other hand, all the users can see their own dashboard. ‘manage_options’ capability is completely NOT the condition of browsing dashboard.

    In fact, ‘wp_dashboard_setup’ hook is already promised to be triggered on browsing dashboard. It’s no need to judge capability, wp has done that.

    So I think just remove “if(!current_user_can(‘manage_options’))” is necessary.

  12. VonfefLef says:

    Here i keep rest some fearsome clarinets instead of foremost prices. Soprano clarinets combine the classic splendid, melodious tones people typically keep troop with this most prolific person in the woodwind family.
    Buy Clarinets

  13. CoolBoii.com says:

    Matt Pealing,

    WordPress changed the way they implemented the Recent drafts widget. Instead of defining it as a normal widget, define it as a side widget. It says on the codex.

    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);

Leave a Reply