10 Techniques for Customizing the WordPress Admin Panel

Apr 1 2011 by Filip Stefansson | 42 Comments

10 Techniques for Customizing the WordPress Admin Panel

A while back, I wrote a guide on how to improve the WordPress Admin Panel as an exploration of how we can customize the user interface of WordPress for end-users. In this post, I’ll take you even further with some awesome tricks, techniques and snippets from my website, WP-Snippets.

In the previous post, we removed a lot of clutter and things that we didn’t need. Now we’ll focus on things that happen behind the scene that can enhance the user experience.

Before You Get Started

If you don’t know what a filter or hook is, make sure to look at my previous post to learn about them. Alternatively, you can visit the WordPress Codex documentation on filters and hooks.

Most of the code we’ll cover will go in functions.php, so you have to create one in your theme folder if you don’t have one. This is a file that WordPress automatically checks before your template is loaded, so all the code in it will be executed.

Some of the code we’ll cover will be placed in wp-config.php, which is found in the root folder of your WordPress installation.

Let’s get started!

1. Remove the Admin Bar

WordPress 3.1 introduced a new Twitter-like admin menu bar.

If you don’t like it, you can disable it by putting the following in functions.php:

add_filter( 'show_admin_bar', '__return_false' );

2. Specify the Auto-save Interval

WordPress has an auto-save feature for when you are writing a new post or a page so that in case your web browser crashes or your computer shuts down unexpectedly, you don’t lose all of your work.

It’s a good feature, but personally, I think it auto-saves way too often, which might slightly affect a website’s performance. Alternatively, you might be thinking WordPress doesn’t auto-save frequently enough.

Whatever the case may be, there’s a way to specify the interval in which WordPress performs auto-saves.

To specify the interval that WordPress should auto-save, you just have to put a single line of code in wp-config.php:

define('AUTOSAVE_INTERVAL', 600); // 60 * 10, auto-saves every 10 minutes

Note that the time unit is seconds. Above, it will save every 600 seconds (or every 10 minutes).

3. Disable Auto-save

Some people may prefer to disable the auto-save feature completely. This is done in functions.php by adding this action:

function no_autosave() {
  wp_deregister_script('autosave');
}

add_action( 'wp_print_scripts', 'no_autosave' );

4. Reduce or Disable Revisions

Post revisions are another great feature in WordPress. It saves different instances of your post so that you can revert to previous versions. However, this can easily get out of hand since WordPress doesn’t have any limit on how many revisions is allowed.

If WordPress creates revisions frequently, it can make it difficult to find the version you need. Most importantly, many versions of a post can occupy more space in your WordPress database than you need it to.

To limit the amount of post revisions (or to disable post revisions altogether), add the following to your wp-config.php file:

define('WP_POST_REVISIONS', 5); // Maximum 5 revisions per post
define('WP_POST_REVISIONS', false); // Disable revisions

5. Empty Trash Automatically

The Trash feature was introduced in WordPress 2.7, and since then, WordPress content that you delete gets staged there. It’s great for fault-tolerance in case you accidentally delete something you didn’t mean to. The feature works similarly to the Recycling Bin feature on Windows or the Trash feature in Mac OS.

Once you empty the Trash in WordPress, it is permanently deleted from the database. It is therefore important to empty your Trash regularly to keep your database in clean, tip-top shape.

Though the Trash feature is a welcome addition to WordPress, just like in real life, taking out the trash is a burden, and it would be much more convenient if someone else did it for you. Luckily, WordPress doesn’t mind doing the heavy lifting for you.

Just add this line to wp-config.php and you’re done:

define('EMPTY_TRASH_DAYS', 5 ); // Empty trash every 5 days

6. Remove the Visual Editor

If you are a web developer like me, you are probably scared of the visual editor in WordPress. Enter it, and it may mess up your nice HTML markup, especially when you’re posting code.

I always disable the Visual Editor for my own websites, just to make sure I don’t accidentally switch over to it.

It’s possible to disable it conditionally for each WordPress user by going to Users > Your Profile. However, if you want to remove it completely, you can add the following filter:

add_filter('user_can_richedit' , create_function('' , 'return false;') , 50);

7. Edit the Help Dropdown Text

If you take a look at the top right of the WordPress Admin panels you’ll see a button that says "Help." When you click it, Help text slides down.

This is a great place to add your own custom Help text for a client. You can even customize it for different Admin panels. For example, you can add a different Help text for the Add New Post panel and another one for the Comments panel.

Here’s how you go about it:

add_action('load-page-new.php','custom_help_page');
add_action('load-page.php','custom_help_page');
function custom_help_page() {
  add_filter('contextual_help','custom_page_help');
}
function custom_page_help($help) {
  // echo $help; // Uncomment if you just want to append your custom Help text to the default Help text
  echo "<h5>Custom Help text</h5>";
  echo "<p> HTML goes here.</p>";
}

To find what file you should add the action to, just check the address bar in your browser and add the load- prefix right before the file name. For example, if you wanted to add the custom Help text to the Add New Post panel, which has a file name of post-new.php, then you would use load-post-new.php as the parameter of the add_action function shown above.

8. Change the Contact Info Form

In the User settings, there is a web form called Contact Info. It has input fields for the user’s AIM account, Yahoo IM account, and so on.

But how about Twitter? What about Facebook? Out of the box, the Contact Info panel doesn’t have these input fields.

If you have multiple users on your WordPress blog, you might want to add new fields and remove old ones.

This is how you do it:

function new_contactmethods( $contactmethods ) {
  $contactmethods['twitter'] = 'Twitter'; // Add Twitter
  $contactmethods['facebook'] = 'Facebook'; // Add Facebook
  unset($contactmethods['yim']); // Remove Yahoo IM
  unset($contactmethods['aim']); // Remove AIM
  unset($contactmethods['jabber']); // Remove Jabber

return $contactmethods;
}

add_filter('user_contactmethods','new_contactmethods',10,1);

WordPress automatically does all the database work for you.

9. Change Role Capabilities

This is a handy snippet if you have multiple contributors on your WordPress website. The following code snippet allows you to change what the different WordPress user roles can and can’t do.

$edit_contributor = get_role('contributor'); // Get the user role
$edit_contributor->add_cap('upload_files'); // Contributor can now upload media
$edit_contributor->remove_cap('delete_posts'); // Contributor can no longer delete posts

A full list of roles and capabilities you can add or remove can be found here.

Important: The capabilities are written to the database, so if you want to give back a capability to a user role, you have to use the add_cap function to reverse the removal (and, vice versa, use remove_cap if you want to remove a capability you added in this fashion).

10. Check User Capabilities

This is extremely useful when you want to allow certain user roles to see certain things depending on their capabilities. This is done with conditional tags.

if( !is_admin() ) {
  add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
}

Using is_admin() is one way to do it, but there is also a function called current_user_can() that lets you specify what capability the user needs to possess in order to see whatever it is you’re conditionally hiding.

if( current_user_can('edit_pages') ) {
  // True if user can edit pages
}

if( !current_user_can('delete_private_posts') ) {
  // True if user can't delete private posts
}
if( current_user_can('activate_plugins') ) {
  // True if user can activate plugins
}

Related Content

About the Author

Filip Stefansson is a Swedish developer. He’s the founder of WP-Snippets and co-founder of Pixby. You can connect with Filip on Twitter.

42 Comments

Randy

April 1st, 2011

I thought the last article was great, but #7 is just fantastic! I am always looking for ways to drop notes to clients within the admin.
My functions file has been filled with sixrevisions stuff over time.
Thanks!

Simon Johnstone

April 1st, 2011

some great tips cheers

Kawsar Ali

April 1st, 2011

Always love wordpress hacks. Changing the contact info from is best one for me

Anand Kumar

April 1st, 2011

Thanks for sharing! I used some of the tips. but which file i should edit to customize CONTACT INFO FORM (Point no 8)?

Matthew Muro

April 1st, 2011

#9 should really be done with a plugin, especially if you aren’t too familiar with the WP caps.

I recommend the Members plugin.

AJ Clarke

April 1st, 2011

These are some nice little code bits. Disabling post revisions is the best tip ever, I will definitely use this one.

Omegakenshin

April 1st, 2011

Excelent share of tips!! I will make good use of these!! thanks!! :D

Chris

April 1st, 2011

Great article Filip, thanks for posting it. I’ve already tried #9 and it works great. I can’t wait to try out the rest of them. ~ Chris

Filip Stefansson

April 1st, 2011

@Anand Kumar: Add the snippet to functions.php in your theme folder.

Fabrizio

April 1st, 2011

Top tips Filip, the reduce or disable revisions came in very handy, thanks again.

Laurent Holdrinet

April 1st, 2011

Thanks for these useful tips.

The “Change the Contact Info Form” is what I needed (among other things).

Alex

April 1st, 2011

Nice lineup!

Alltough the first one is easily done through a standard setting in the original admin. You can disable the admin bar in the user settings

Shawn

April 1st, 2011

I love this site, always has useful tips and tricks to implement. Well done.

Mohan Arun

April 1st, 2011

If you make any modifications in any wordpress php files other than the wp-config.php, the next time you hit “Update WordPress to latest version” it will overwrite all the mods you made.

Mark Bruce

April 2nd, 2011

Thank you for sharing great tips. These things are simple but it helps lot for us as wordpress developers

edie

April 2nd, 2011

Very nice articles, i’ll try this practice as soon as posible. thanks

Giannis

April 2nd, 2011

Very good article Filip! We want more articles for WordPress :)

krike

April 2nd, 2011

nice list, extremely usefull thanks :D

Emil

April 2nd, 2011

The filter “Remove Admin Bar” is not needed, simple because you can hide/show the Admin Bar via WordPress built-in option from User’s Profile just under Personal Options.

Cheers,
Emil

Matthew Snider

April 2nd, 2011

Great article brother. Thanks a bunch. Off to play with a few things now!

Tech Crates

April 3rd, 2011

Excellent tips to effectively customize WP admin panel…

saqib sarwar

April 3rd, 2011

Thanks for sharing these useful snippets.

I would encourage you to write about customizing admin panel menus as every client do not need the every menu. I know there are plugins for this but it would be great to have something smart as part of the theme.

Thanks again :)

Rachel

April 3rd, 2011

Really useful list here! I’m definitely going to be removing the revisions :)

Usman

April 3rd, 2011

really good idea for renovating the wordpress blog admin dashboard. Thanks for the useful tutorial

Kevin Thomson

April 3rd, 2011

That’s a really cool little collection of tips! I didn’t know you could add things to the help menu – i’ll be trying that out in my next site!

Filip Stefansson

April 4th, 2011

@saqib sarwar: Check out my other post on customizing the admin area here on Six Revisions: http://sixrevisions.com/wordpress/how-to-customize-the-wordpress-admin-area/, there you’ll find what you’re looking for.

juhart@post.com

April 4th, 2011

Hi Filip, this is a great bunch of codes and worked for me!
I’ve been desperately trying for 3 days to find a way of removing the fields from “personal options” section in the profile page – where it says “admin color scheme” and “show admin bar” – If you or any of your readers have any idea how this could be accomplished that would be amazing.

vitmel

April 5th, 2011

Thanks for these tips. I will definitely delete something from my admin panel after reading this article.

Tom Durkin

April 8th, 2011

Very neat tips thanks for sharing!

PauliusR

April 11th, 2011

Thank you for the tips related to WordPress auto-save feature. I was concerned about how my database is growing because of dozens of auto-saved bits for each post

Kesha

April 13th, 2011

Thank goodness I found this article! I was looking for ways to do some of these things…

I didn’t even know you could change most of this stuff!!

Thanks for sharing these customizations with us!

Jatin

April 22nd, 2011

Great tips.

I was looking out for controlling revisions, and found here (Tip 4: Reduce or Disable Revisions).

Thanks.

pawan

April 27th, 2011

awesome tips…thanks

Mohit

May 1st, 2011

Good work Filip. Thanks for sharing this with all of us.

JoE Martin

May 10th, 2011

Dude! THESE are the kind of articles I’ve been looking for. Clean, clear, concise. Wonderfully put! Checking out WP-Snippets right now.

MUHAMMAD SALMAN

May 12th, 2011

Can we customize the add post screen of the admin , so that we place html controls on it and the values comes form the database.

e.g we want rating a post upon its creation , so on the add post screen we have a pull down menu with values 1 to 5 from DB , we select it and write the post.
Plz tell me how can we achieve this.

Thanks

atozvision

May 26th, 2011

Thanks for these useful tips.

ホームページ作成 春日井

July 29th, 2011

I just started dealing with WordPress. I worked hard up unusable. And various helpful. Thank you.

Robin Jennings

July 29th, 2011

I really like #1, the new admin bar annoys me know end as I often have a sliding contact at the top of each page.

And every time I show a client their website they freak out thinking that all people will see the WP admin bar when they visit their site- so thank you, you’ve saved me a lot of explaining.

Torbjörn

August 16th, 2011

Thanks for a great article. I found it when i searched for a solution to my customization i want to do to the ‘Upload Media’ popup in WordPress admin. Maybe someone can point me in the right direction.
I would like to add a custom div with text to the ‘upload media’ dialog (media-upload.php). Tips please.

Katie

September 23rd, 2011

Well, this is awesome. As long as you are not telling me to use a plugin i am your fan.

When you can do simple stuff with WP Filters why should we use an extension anyways. I noticed that just to remove the Admin Toolbar there are numerous plugins :) that’s funny huh!

ICWordpress

November 21st, 2011

A question on item 7, that is “Edit the Help Dropdown Text”

When you upgrade the wordpress code, say from 3.2.1 to 3.2.2, wouldn’t the changes you put in the load-add-new.php will get overwritten?

Should’nt this be done by hooks and if so, where would you put the hooks? functions.php of the current theme? Then, when you switch themes, then those changes are also be ignored by the new functions.php? What’s the best course of action to deal with such maintenance?

Leave a Comment

Subscribe to the comments on this article.