Friends, In this article we will introduce you to some quick hacks on the WordPress dashboard. When you are developing a site for a client, sometimes they wont like to have the multiple wordpress logos, news, widgets etc in their dashboard. So here are some quick tips on how to customize wordpress dashboard. You need to add the following codes to theme’s functions.php file.
1]Add custom WordPress dashboard logo
Inorder to add a custom logo to your wordpress admin panel use the following code
add_action('login_head', 'my_wordpress_custom_login_logo'); function my_wordpress_custom_logo() { echo "<img src='location_to_my_img'>"; }
2]Remove wordpress dashboard widgets
It is not good to show the dashboard widgets like whats happening, blog rolls etc to the users. So to remove that use the following code
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' ); function remove_dashboard_widgets() { global $wp_meta_boxes; 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']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); }
3]Add extra widgets to wordpress dashboard
In some cases we need to have some custom widgets in the wordpress dashboard. We can achieve it by
function custom_dashboard_widget_function() { // Display whatever you want to show echo "Hello World, I'm a great Dashboard Widget"; } // Create the function use in the action hook function custom_add_dashboard_widgets() { wp_add_dashboard_widget('custom_dashboard_widget', 'Custom Dashboard Widget', 'custom_dashboard_widget_function'); } // Hoook into the 'wp_dashboard_setup' action to register our functions add_action('wp_dashboard_setup', 'custom_add_dashboard_widgets' );
4]Remove the “Upgrade now” notification
There can be a catastrophic output in some cases when the client upgrades the site. So a better way is to disable the upgrade notification. To disable it
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;" ) ); }
5] Remove default fields from the wordpress profile
In some cases, we need to remove the user profile fileds like bio, aol, jabber etc. Use the following code for that
function profile_admin_buffer_start() { ob_start("remove_plain_bio"); } function profile_admin_buffer_end() { ob_end_flush(); } add_action('admin_head', 'profile_admin_buffer_start'); add_action('admin_footer', 'profile_admin_buffer_end'); add_filter('user_contactmethods','hide_profile_fields',10,1); add_action('admin_head','hide_personal_options'); function remove_plain_bio($buffer) { $titles = array('#<h3>About Yourself</h3>#','#<h3>About the user</h3>#'); $buffer=preg_replace($titles,'<h3>Password</h3>',$buffer,1); $biotable='#<h3>Password</h3>.+?<table.+?/tr>#s'; $buffer=preg_replace($biotable,'<h3>Password</h3> <table>',$buffer,1); return $buffer; } function hide_profile_fields( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); unset($contactmethods['url']); unset($contactmethods['pre_user_url']); return $contactmethods; } function hide_personal_options(){ echo "n" . '<script type="text/javascript">jQuery(document).ready(function($) { $('form#your-profile > h3:first').hide(); $('form#your-profile > table:first').hide(); $('form#your-profile').show(); });</script>' . "n"; }
You can find three more extra hacks in our previous blog.
Tags: add more fields to wordpress, add wordpress widgets, extra widgets for wordpress, remove wordpress profile info, remove wordpress upgrade now, remove wordpress widgets, wordpress dashboard, wordpress hacks