10 useful tips for WordPress dashboard customization

The dashboard is a very important part, as it is where you – the admin – publish content and control everything about your blog. In this article, I have compiled over 10 WordPress hacks and snippets for WordPress develoipers to customize the dashboard.

Keep logged in on WordPress for a longer period

A very handy code snippet, which enables to stay logged in for a longer period of time. Add the code to functions.php and adjust the amount of seconds if needed ( line 3).

add_filter( 'auth_cookie_expiration', 'stay_logged_in_for_1_year' );
function stay_logged_in_for_1_year( $expire ) {
  return 31556926; // 1 year in seconds

Source: Labnol

Remove dashboard menus

When a WordPress developer builds 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 code into 
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: Hungred

Require a featured image before you can publish posts

If your blog layout is set to display a featured image, it can be useful to prevent post publishing th post without the features image set.
This code has to be pasted into your 
functions.php file.

add_action('save_post', 'wpds_check_thumbnail');
add_action('admin_notices', 'wpds_thumbnail_error');

function wpds_check_thumbnail( $post_id ) {
  // change to any custom post type 
  if( get_post_type($post_id) != 'post' )

  if ( ! has_post_thumbnail( $post_id ) ) {
    // set a transient to show the users an admin message
    set_transient( "has_post_thumbnail", "no" );
    // unhook this function so it doesn't loop infinitely
    remove_action('save_post', 'wpds_check_thumbnail');
    // update the post set it to draft
    wp_update_post(array('ID' => $post_id, 'post_status' => 'draft'));

    add_action('save_post', 'wpds_check_thumbnail');
  } else {
    delete_transient( "has_post_thumbnail" );

function wpds_thumbnail_error() {
  // check if the transient is set, and display the error message
  if ( get_transient( "has_post_thumbnail" ) == "no" ) {
    echo "<div id='message' class='error'><p><strong>You must add a Featured Image before publishing this. Don't panic, your post is saved.</strong></p></div>";
    delete_transient( "has_post_thumbnail" );

Source: WP Snipp

Place a custom logo in dashboard

Just as a clients will love to see their own logo on WordPress login page, they might ask the WordPress developer to place 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: Smashing Magazine

Remove dashboard widgets

Introduced in WordPress 2.7, dashboard widgets can be pretty useful. For example, a WordPress developers 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

        // Remove right now

// Hook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

Source: Hankis

Add custom login logo

Although it is unimportant for the blog performance or usability, most clients will appreciate their own logo on the dashboard login page,.
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; }

add_action('login_head', 'my_custom_login_logo');

Source: WPRecipes

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');
// Hook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

Source: 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 custom help messages

When Wordpress developers build a site for a client and they have 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: Studio Grasshopper

Remove dashboard widgets for specific user roles

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;

     //if current user level is less than 3, remove the postcustom meta box
     if ($current_user->user_level < 3)


Source: Smashing Magazine

Reduce amount of post revisions

Post revisions are very useful, but they also clutter your database. In order to save  space, you can consider limiting the amount of post revisions automatically saved by WordPress.
This code has to be pasted in your 
wp-config.php file, located at the root of your WordPress install.

define( 'WP_POST_REVISIONS', 3 );

Source: WordPress Codex

Disable WordPress Login Hints

When you (or someone else) fails to login on your WordPress dashboard, an error message is displayed. While this can be useful to legit users, it can also give precious information to a potential hijacker.
Paste the code below into your 
functions.php file to prevent login error messages to be displayed.

function no_wordpress_errors(){
  return 'GET OFF MY LAWN !! RIGHT NOW !!';
add_filter( 'login_errors', 'no_wordpress_errors' );

Source: Labnol