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.
Nice! Always wanted to implement this but never actually looked it up.
thanks.
Wrap this in a plugin and millions will love you
Will this speed WP up in any way? Or is it just a visual improvement?
It’s a visual change only. And it’s useful mostly to unclutter the wordpress interface for novice users.
huge tips, any one can to turn it to a plugin?
Nice tip!… Great for client projects.
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']);
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.
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.
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']);
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.
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
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']);