I have been so much fan of wordpress, but one thing wordpress lacks, is a backend user interface (login area for users). If you are presenting this to your client, there are lot of tweaks to do, remove unwanted things in the user interface area. The good news is with just few bits of code you can do amazing things with wordpress and impress your clients.
Remember whatever code is shown below, you must add it to the functions.php which is present in your theme.
1. Removing WordPress update notifications
It is very unprofessional to show your users, “New wordpress versions are available. Please update it”. As a site owner, you may want to hide this notice to users.
[php]
//disable wordpress version update
function hide_update_notice() {
remove_action( ‘admin_notices’, ‘update_nag’, 3 );
}
add_action( ‘admin_notices’, ‘hide_update_notice’, 1 );
[/php]
2. Custom WordPress Notifications for Users
You may want to put up custom notification or warnings to your users, when they login to the wordpress user area. This code will show custom message, within a yellow box on top.
[php]
//my custom admin notice
add_action(‘admin_notices’, ‘admin_notice’);
function admin_notice(){
if(current_user_can(‘contributor’)) {
echo ‘<div>
<p>We only approve unique high quality news content. No spamming please.. </p>
</div>’;
}
}
[/php]
3. Remove Powered by WordPress in Footer
You dont want to show, powered by wordpress in the footer of your user interface. Make changes to it, using the following code
[php]
// Remove Powered by WordPress.org
function modify_footer_admin () {
echo ‘Example.com – My Account Section’;
}
add_filter(‘admin_footer_text’, ‘modify_footer_admin’);
[/php]
4. Show only User Specific Posts
The biggest problem i faced is wordpress by default, shows ALL posts to user, in the admin area. ALL posts means even posts submitted by other users/authors, of course in read only mode. Further wordpress shows total counts of all posts (pending, published, all, drafts) present in the entire blog. This is totally unacceptable and it may present a security risk. You dont want to reveal entire list of blog posts to your users. The solution is to show posts, submitted by the user who is currently logged in and remove all post counts etc.. This is the key to design a best user interface.
Note: I have designated the default user role as “contributor” when they register. You may want to change this, depending on what user role you set, for example author.
This code will only show posts submitted by author/user, who is currently logged in:
[php]
//user specific posts in admin area
function posts_for_current_author($query) {
if(current_user_can(‘contributor’) && is_admin()) {
global $user_ID;
$query->set(‘author’, $user_ID);
}
return $query;
}
add_filter(‘pre_get_posts’, ‘posts_for_current_author’);
[/php]
This post will hide the number counts in brackets:
[php]
// remove pending published above table.
function jquery_remove_counts()
{
if(current_user_can(‘contributor’)) {
?>
<script type="text/javascript">
jQuery(function(){
jQuery("li.all").remove();
jQuery("li.publish").find("span.count").remove();
jQuery("li.trash").find("span.count").remove();
jQuery("li.pending").find("span.count").remove();
});
</script>
<?php }
}
add_action(‘admin_footer’, ‘jquery_remove_counts’);
[/php]
5. Cleanup the Dashboard
Remove the dashboard widgets like incoming links, drafts, plugins, recent comments etc in the user dashboard area.
[php]
function remove_dashboard_widgets(){
global$wp_meta_boxes;
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_recent_comments’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]);
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_recent_drafts’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]);
}
add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’);
remove_action(‘init’, ‘wp_version_check’);
[/php]
6. Custom Logo for Login Area
Why not remove the default wordpress logo and replace it with your own website logo for the login area for your users. Use this code for the custom logo. Be sure to put admin_logo.png in the theme folder inside the images directory.
[php]
// add admin logo
function my_custom_login_logo()
{
echo ‘<style type="text/css"> h1 a { background-image:url(‘.get_bloginfo(‘template_directory’).’/images/admin_logo.png) !important; } </style>’;
}
add_action(‘login_head’, ‘my_custom_login_logo’);
[/php]
7. Replacing Dashboard title with custom text
When ever the user logs in to the dashboard, they will see “Dashboard” in the landing page, which wordpress shows as default. You may want to change this to My Blog – My Account” or something like that…using the following code…
[php]
function change_wp_login_title()
{
echo get_option(‘blogname’) . "- Account Section";
}
add_filter(‘login_headertitle’, ‘change_wp_login_title’);
[/php]
8. Assigning Specific Permissions
This is the most important part in the user interface on how and what permissions you give to your users. For example, if you select contributor as the default user role, you can give permission to them only to edit, delete their posts and NOT publish posts. You as admin, may want to review posts and publish them. Amazingly you can accomplish them with few lines of magic code..
Note: I have assigned the default user role as “contributor”. You may want to change this role accordingly on what you set when users register.
[php]
function add_permissions_contributor() {
$role = get_role(‘contributor’); // first get the role of user.
//$role->add_cap(‘edit_published_posts’); //allow editing published posts
//$role->add_cap(‘delete_posts’); // allow deleting published posts
$role->remove_cap(‘publish_posts’); // prevent publishing posts
$role->remove_cap(‘edit_others_posts’); // prevent editing others posts
}
add_action(‘admin_init’,’add_permissions_contributor’);
[/php]
9. Using Plugins to Tweak Further
You can use plugins like adminimize to further clean up dashboard items like quickpress, without touching the code. You can also add custom menus in your user interface using plugins like Admin menu editor. Dashboard landing page can also be customized to include products/services in the user area.
- Adminimize – wordpress.org/extend/plugins/adminimize/
- Admin menu Editor – wordpress.org/extend/plugins/admin–menu–editor/
- White label CMS – http://www.videousermanuals.com/white-label-cms/
- Dashboard post-it – http://wordpress.org/extend/plugins/dashboard-post-it/