Remove dashboard menus
When building a WordPress blog for a client, it can be a good idea to remove access to some dashboard menus in order to avoid future problems such as the client “accidentally” deleting the custom theme they paid for.
Paste the following code in the functions.php file from your theme directory. The following example will remove all menus named in the $restricted array.
function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
}
add_action('admin_menu', 'remove_menus');
» Source
Define your own login logo
Although it doesn’t have any importance for the blog performance or usability, most clients will be very happy to see their own logo on the dashboard login page, instead of the classic WordPress logo.
The Custom admin branding plugin can do that for you, as well as the following hack that you just have to paste in your functions.php file.
function my_custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.gif) !important; }
</style>';
}
add_action('login_head', 'my_custom_login_logo');
» Source
Replace dashboard logo with yours
Just as a client will love to see their own logo on WordPress login page, there’s no doubt that they’ll enjoy viewing it on the dashboard too.
Simply copy the code below and paste it to your functions.php file.
add_action('admin_head', 'my_custom_logo');
function my_custom_logo() {
echo '<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }</style>';
}
» Source
Disable the “please upgrade now” message
WordPress constantly release new versions. Although for obvious security concerns you should always upgrade; disabling the “Please upgrade now” message on client sites can be a good idea because the client doesn’t necessarily have to know about this, this is a developer’s job.
One more time, nothing hard: paste the code in your functions.php, save it, and it’s all good.
if ( !current_user_can( 'edit_users' ) ) {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
» Source
Remove dashboard widgets
Introduced in WordPress 2.7, dashboard widgets can be pretty useful. For example, some can display your Google Analytics stats. Though, sometimes you don’t need it, or at least don’t need some of them.
The code below will allow you to remove WordPress’ dashboard widgets once you paste it in your functions.php file.
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' );
» Source
Add custom widgets to WordPress dashboard
With the previous example, I showed you how easy it is to remove unwanted dashboard widgets. The good news is that creating your own widgets isn’t hard either.
The well-commented code below should be self explanatory. Just insert it in your functions.php, as usual.
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' );
» Source
Change WordPress dashboard colors
If you ever wanted to be able to change WordPress dashboard colors (as well as font or even display) without having to edit WordPress core files, you’ll like this hack for sure.
The following example features a basic style change (grey header is replaced by a blue one) but you can easily add as many styles as you wish within the <style> and </style> tags.
function custom_colors() {
echo '<style type="text/css">#wphead{background:#069}</style>';
}
add_action('admin_head', 'custom_colors');
Provide help messages
If you’re building a site for a client and they have some problems with some parts of the dashboard, a good idea is to provide contextual help to the client.
The following hack will allow you to add a custom help messages for the blog admin. As usual, you only have to paste the code into your functions.php file.
function my_admin_help($text, $screen) {
// Check we're only on my Settings page
if (strcmp($screen, MY_PAGEHOOK) == 0 ) {
$text = 'Here is some very useful information to help you use this plugin...';
return $text;
}
// Let the default WP Dashboard help stuff through on other Admin pages
return $text;
}
add_action( 'contextual_help', 'my_admin_help' );
» Source
Monitor your server in WordPress dashboard
WordPress dashboard API allow you to do many useful things using dashboard widgets. I recently came across this very useful code: a dashboard widget that allows you to monitor your server directly on WordPress’ dashboard.
Paste the code in your functions.php file, and you’re done.
function slt_PHPErrorsWidget() {
$logfile = '/home/path/logs/php-errors.log'; // Enter the server path to your logs file here
$displayErrorsLimit = 100; // The maximum number of errors to display in the widget
$errorLengthLimit = 300; // The maximum number of characters to display for each error
$fileCleared = false;
$userCanClearLog = current_user_can( 'manage_options' );
// Clear file?
if ( $userCanClearLog && isset( $_GET["slt-php-errors"] ) && $_GET["slt-php-errors"]=="clear" ) {
$handle = fopen( $logfile, "w" );
fclose( $handle );
$fileCleared = true;
}
// Read file
if ( file_exists( $logfile ) ) {
$errors = file( $logfile );
$errors = array_reverse( $errors );
if ( $fileCleared ) echo '<p><em>File cleared.</em></p>';
if ( $errors ) {
echo '<p>'.count( $errors ).' error';
if ( $errors != 1 ) echo 's';
echo '.';
if ( $userCanClearLog ) echo ' [ <b><a href="'.get_bloginfo("url").'/wp-admin/?slt-php-errors=clear" onclick="return confirm(\'Are you sure?\');">CLEAR LOG FILE</a></b> ]';
echo '</p>';
echo '<div id="slt-php-errors" style="height:250px;overflow:scroll;padding:2px;background-color:#faf9f7;border:1px solid #ccc;">';
echo '<ol style="padding:0;margin:0;">';
$i = 0;
foreach ( $errors as $error ) {
echo '<li style="padding:2px 4px 6px;border-bottom:1px solid #ececec;">';
$errorOutput = preg_replace( '/\[([^\]]+)\]/', '<b>[$1]</b>', $error, 1 );
if ( strlen( $errorOutput ) > $errorLengthLimit ) {
echo substr( $errorOutput, 0, $errorLengthLimit ).' [...]';
} else {
echo $errorOutput;
}
echo '</li>';
$i++;
if ( $i > $displayErrorsLimit ) {
echo '<li style="padding:2px;border-bottom:2px solid #ccc;"><em>More than '.$displayErrorsLimit.' errors in log...</em></li>';
break;
}
}
echo '</ol></div>';
} else {
echo '<p>No errors currently logged.</p>';
}
} else {
echo '<p><em>There was a problem reading the error log file.</em></p>';
}
}
// Add widgets
function slt_dashboardWidgets() {
wp_add_dashboard_widget( 'slt-php-errors', 'PHP errors', 'slt_PHPErrorsWidget' );
}
add_action( 'wp_dashboard_setup', 'slt_dashboardWidgets' );
» Source
Remove dashboard widgets according to user role
If you’re owning a multi-user blog, it may be useful to know how to hide some dashboard widgets to keep confidential information in a safe place.
The following code will remove the postcustom meta box for “author” (role 2). To apply the hack on your own blog, just copy the code below and paste it in your functions.php file.
function customize_meta_boxes() {
//retrieve current user info
global $current_user;
get_currentuserinfo();
//if current user level is less than 3, remove the postcustom meta box
if ($current_user->user_level < 3)
remove_meta_box('postcustom','post','normal');
}
add_action('admin_init','customize_meta_boxes');
» Source





My name is Jean-Baptiste Jung and I'm the man behind Cats Who Code. I started to use the Internet back in 1998 and started to create websites three years laters in 2001.
65 Comments
Nice one, I am going to use first logo & color hack for wordpress dashboard
There are plugins for most of these. No need to dig through code plus you have to re-edit the code each time you upgrade wordpress
The functions file doesn’t get over-written during upgrades.
help messages and the last tip saved my time,
wiiiihaaa!
Don’t edits to functions.php get overwritten during upgrades?
@Dani : No, it doesn’t.
Hey Jean-Baptiste,
cool hacks. I hope you have some more dashboard hacks in the future. These seem very useful and i’ll definetly use them for some client work in the future. Right now i find it very interesting (and i hope that future WP updates or plugins will make the job even easier).
When i see all this cool hacks and themes and just everything i am thinking of becoming a programmer instead of a marketer to fulfill my theme dreams.

Or hiring one exclusive programmer.
Thanks and enjoy your time!
Very handy article man
Thanks for post, very good article
These are some great wordpress hacks. These are going to help me out a lot with building blogs for clients. Thanks for all your work!
It’s crazy to see Wordpress growing like a weed! I remember back when Wordpress was released in beta still trying to kick out all of the bugs, and now look how far it’s gotten. These are some great hacks and I appreciate sharing them on the blog – I look forward to your next post
Awesome. It’s never really occurred to me that I could or even would change the Login & Dashboard logos. Now I’m going to go for it! Why not, eh?
These are some interesting and useful tips! I’ll put some of them to use, and see how well they work.
I rarely come across articles on customisation of the WP dashboard. Great article only 1 out of 10 hacks I didn’t find any need fore!
This stuff can really take your themes or site to the next level.
Happy New Year
I really appreciate these types of articles……marvelous.
It’s certainly a good list! Thanx! Been looking for this.
I’d love to find a hack that would display my Google Analytic info in the admin control panel for me to see instead of having to go to the GA site.
Hint hint!
Thanks for this – very helpful… I need to try out couple of them today.
Hi there,
For the hack on removing menus from the dashboard, is it possible to define for which users the menus should be removed?
Yet another helpful article. I love this blog.
@Peter Steen Høgenhaug : Sure you can. Have you checked the source of this snippets? It features some interesting examples.
I found your site through a Google search for WP plugins to alter the dashboard. I’m loving it and will be back to read more! What I was looking for, was a dashboard widget that lets you post announcements in the dashboard. We have several authorized users who post at intervals, and I wanted something to relay info about changes to the site, tips, etc.
Do you know if such a creature exists?
wow this cool.., thank you for the tutorial
Happy New Year 2010
I am sure these will help a lot of people, but I have never seen as much procedural horse manure in my life – that is just the problem with WP, it is just a bunch of procedural functions pasted together.
I do not expect a lot of people to understand where I am coming from, where my background is software engineering – proper software development using object oriented methodologies, etc.
WP is building up a big mess for it’s self as I have not in the years of WP seen any serious improvements on the codebase, and now we have members of the public making contributions to a codebase who are not particularly from a development background.
Hell, please continue as the day WP goes down the crapper moves ever closer! Well done.
@Les : You’re probably a better programmer than me, but still, I don’t see what’s wrong with procedural programming in WP.
If you have OO equivalents for the functions above, do not hesitate to share them with us.
Heh, I guess the last snippet kind of tells me how to do that… Thanks, Jean-Baptiste!
That server monitor one sounds ace, gonna give that a try now!
Not really made any use of the dashboard since they implemented it so maybe this will be a good chance to start messing.
Another helpful post! I have been ‘hiding’ things from the clients by simply adding some styling to the functions.php such as:
li#menu-appearance { display:none;}
The above hides the Appearance area and so on.
Firebug shows you all you need to know.
You can also conditionally check the user level with get_currentuserinfo(); to see who sees what.
Thanks!
Wow this is great, it never occurred to me to hack my dashboard, but now I can see the possibilities, especially when setting up a wordpress site for customers. It would be great to display my phone number under a “Support” widget on the dashboard!
Now that you mentioned Google Analytics, I would love! to have my analytics displayed in a dashboard widget. Any idea how? I bet there must be a plugin for that.
Found it – Google Analytics Dashboard (it’s a plugin) displays your google analytics right on your dashboard woohoo!
Thanks a lot for some of these dashboard hacks, definitely better than to have to download a plugin.
Wow.. I am going to give this a try with my Wordpress blog. I am too used to Blogger so I don’t know much about Wordpress.
Thanks for the tip! I like it
Hey, thanks for the hacks! I am most definitely going to be implementing some of these.
I suppose that if you wanted to make it more OO, you would. I’d think that instead of whining about it, one would do something about it.
Any idea how to remove default panels such as Trackbacks or Discussion in the Write Post page?
I’ve seen it done somewhere through functions.php and it was very similar to removing the wp generator metatag (remove_action(’wp_head’, ‘wp_generator’); ), but now I can’t find it anywhere.
Please help anyone
A very nice article. Thanks for your hacks…
thank you a lot for the tutorial, really useful!
I am going to implement this color changes of dashboard.
COOL!
Another helpful post! I have been ‘hiding’ things from the clients by simply adding some styling to the functions.php
love your blog!
Thanks for the hacks, sure to have a look at them. I would say that the 1st one would be ‘Remove dashboard widgets according to user role’, I think thats one I will impliment soon.
Cool … Thanks for these tricks specially that Logo Change for Admin login.
Hey Jean Baptiste,
this tips are exactly the things i’ve looked for.
I enjoy every day to read your blog and the CWC Blog too.
Don’t stop your working with this
@Peter Steen Høgenhaug
This should do what you need:
if($current_user!=’yourusername’){
add_action(’admin_menu’, ‘remove_menus’);
}
http://codex.wordpress.org/Function_Reference/wp_get_current_user
wow… thanks for those tips. it’s a great way to keep pesky people from messing with WP too much. It’s good to keep everything as simple as possible for some clients… I’m sure you know what I mean.
For those who’d like to remove dashboard widgets according to the user’s role (eg, Subscriber or any other role), I think this will do the trick…
if ( is_user_logged_in() ) {
$userRole = ($current_user->data->wp_capabilities);
$role = key($userRole);
unset($userRole);
switch($role) {
case ’subscriber’:
case ‘anotherole’:
add_action(’admin_menu’, ‘remove_menus’);
break;
default:
break;
}
}
Hello. QUESTION: I love the idea of editing the admin panel for selected users. Waht I need to be able to do is allow a client to EDIT posts and pages, but not allow them to ADD NEW posts and pages.
Can someone please assist me with this or point me in the right direction. Any help would be greatly appreciated.
Thanks ~ Erik
Thank you. Very helpful.
Thank’s for the tutorial
Is there a way to pull in a custom RSS feed to the dashboard? To have a feed of tips coming in for a category of the developers blog.
Never mind. Didn’t know you could configure the built in RSS feed.
Nice hacks. I’m new to this wordpress hacking stuff. I started providing tutorials on it. If possible include this to your upcoming post [How To]Generate Goo.gl Short URL Without Any Worpress Plugin
Great article! I plan on playing with several of the above hacks.
But for now, I have a general question. I’d like to make my *own* hack. (Basically, I want to edit some text in one of the admin files.) So, how would I do that without editing core files? Copy and paste the function into my functions.php file? I tried that, and so far, it doesn’t seem to be working…
Ramsey,
You can only overwrite core functions that are in pluggable.php. Many core functions use filters though, so you can add a filter to one of those to manipulate the output that it returns.
Robert, interesting! I guess you learn something new everyday. So, if the core function that I am wanting to work with has a filter, how do I figure that out? Any good articles or blog posts out there? (I’m a frontend designer, not a backend developer.
) Thanks!
Excellent tips for wordpress, i like the concept of removing the delete menu from Dashboard as it is important to keep ti away from novice as it will mess all the things. great job bravo.
Great hacks! Many I’d love to implement for clients, but… I’m getting some errors.
Sorry to be a newbie about this… but I keep getting php error messages when I copy and paste the code. Are there any special tricks to this? Any particular place the code needs to go? Do you need to add extra to the code?
Currently running 2.9.1… is there something about this version that would preclude me from using these hacks?
Very useful information, thank you.
Its such a nice post. you must have worked very hard to get all these hacks and will be really handy and useful resource whenever needed. Good work. Thanks a lot.
Salut, merci encore pour cette très bonne liste très utiles. J’ai juste une petite question : comment supprimer le tableau de bord de “cforms” car $restricted = array(__(’cforms’) ne donne rien (c’eut été trop facile
Merci d’avance !
Hello Bruno, je n’utilise pas cForms mais je pense qu’il faut récupérer le nom qui est utilisé pour la création du menu et utiliser ce nom dans $restricted = array(__(’le_nom_utilise_par_cforms’).
Great, great article. As someone who uses WP as a CMS, these hacks are invaluable. Nice to know we don’t always have to rely on the sometimes-unreliable plugin version – we can control this stuff ourselves. Kudos!
Perfect, just what I was looking for. Thanks in advance.
These are amazing thank you so much…I didn’t think any of this was possible and my clients will love me for finding them!!
Incredibly useful! Thanks a ton.
Very nice blog, I have just bookmarked this article, I will need a while to understand the codes as a beginner, Thanks
8 Trackbacks
[...] to hungred for this very useful trick! This recipes was previously featured in Cats Who Code 10 WordPress dashboard hacks [...]
[...] ÑÑ‚Ð°Ñ‚ÑŒÑ ÑвлÑетÑÑ Ð¿ÐµÑ€ÐµÐ²Ð¾Ð´Ð¾Ð¼, оригинал можно прочеÑть тут. tweetmeme_url = [...]
[...] Lukemalla Wordpressin Codexia löytyy aika suoraan ohje asian käsittelyyn. Myöskin esim. CatsWhoCode.com- sivuilta löytyy asiaa käsittelevä blogi- teksti. [...]
[...] 10 WordPress dashboard hacks [...]
[...] 10 WordPress dashboard hacks (tags: wordpress dashboard) [...]
[...] à l’emploi) pour mettre l’administration de votre blog Wordpress à vos pied ? Voici 10 WordPress dashboard hacks proposés par Cats Who Code membre du Smashing Network depuis peu. Au menu [...]
[...] CatsWhoCode. 0 [...]
[...] 10 WordPress dashboard hacks [...]