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 "Custom Help text

"; echo " HTML goes here.

"; } 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_contactmetho ds',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 20-year-old web developer from Sweden who is a WordPress fanatic. He runs WP-Snippets and Pixby. You can connect with Filip via Twitter.




More...