modifying the WordPress Dashboard

by webhank on June 9, 2009

in Articles, Tutorials

a site i am currently deploying on WordPress will have many of the users actually accessing the admin area of the site. as such, i wanted to modify the default dashboard, clean up a few things and add some messaging to the users – a “welcome to the admin area” if you will. i looked for a plugin to do this for a bit, but didn’t find anything that i was satisfied with so i checked out the codex and it was no huge surprise when i found most of what i needed there.

First i wanted to remove some of the default admin widgets – that was easily accomplished with the following code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Create the function to use in the action hook
function example_remove_dashboard_widgets() {
	// Globalize the metaboxes array, this holds all the widgets for wp-admin
 
	global $wp_meta_boxes;
 
	// Remove the incomming links widget
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);	
 
	// Remove right now
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
 
// Hoook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

check out the codex link above to see how to view each widget’s call.

next i wanted to create a widget that welcomed our users to the dashboard – again pretty straight forward – the code below took care of it.

1
2
3
4
5
6
7
8
9
10
11
12
// Create the function to output the contents of our Dashboard Widget
function example_dashboard_widget_function() {
	// Display whatever it is you want to show
	echo "Hello World, I'm a great Dashboard Widget";
} 
 
// Create the function use in the action hook
function example_add_dashboard_widgets() {
	wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
}
// Hoook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

I added these to my theme’s functions.php file – but you could create a php file with these functions in it and upload it to the plugins directory and get the same results.

Got a better way of doing this? Leave a comment!

{ 3 comments… read them below or add one }

Adam June 9, 2009 at 8:21 pm

This is great! Makes it easy to make the client feel like they’re getting something more than an off-the-shelf CMS.

Reply

Philip Downer January 15, 2010 at 11:51 pm

Just wanted to say a quick “Thank you” for the tutorial! Cool stuff…

Reply

Tracy April 10, 2010 at 9:04 am

Thanks for posting!
Worked Great.

Reply

Leave a Comment

Previous post:

Next post: