7 Ways to Customize WordPress for your Users

WordPress has been considered as one of the most simplest Content Management Systems. It offers a very clean user interface. Offering significant power, this free open source content management system is easier to install.

However, sometimes WordPress can get daunting even for those who use it frequently. If not used carefully, it can invite a malicious plugin or wipe a database. Scary isn’t it?

Luckily, the CMS can be configured and customized to avoid problems. Here’s how to go about it:

1. Create Shortcodes

Many users demand advanced functionality. Some of the most commonly demanded include stock price trackers, affiliate links, Twitter widgets, etc. Here, it is important to restrict your users from adding arbitrary third-party code. In fact, you can let them call your code through a shortcode defined in functions.php file’s theme or a plugin. The following shortcode recommended by most reputed WordPress maintain service providers will allow your users to enter [include myfile] in the editor for including myfile.php from the template folder:

// include a specific PHP file
function customIncludeFile($params = array()) {

extract(shortcode_atts(array(
‘file’ => ‘contact-form’
), $params));

ob_start();
include(get_theme_root() . ‘/’ . get_template() . “/$file.php”);
return ob_get_clean();
}

add_shortcode(‘include’, ‘customIncludeFile’);

2. Allot User Roles

One of the best things about WordPress is that it offers a wide range of roles and capacities. Users may be any of the following in most cases:

  • A Contributor – Can write and manage their own posts without being able to publish any of them.
  • An Editor – Can publish and manage their posts for themselves and others.
  • An Author – Can publish and manage their own posts.

The above stated roles cannot do the following:

  • Install plug-ins
  • Change themes
  • Approve updates
  • Edit files
  • Perform other dangerous tasks available to Administrators

Although some users would demand full rights, they should also be prepared to take the risks involved.

3. Get Rid of Unnecessary Menus

Only a few websites use all WordPress features. An example of this is that an installation may not require the commenting functionality. You can easily eliminate unnecessary items by using the following code in a plugin or functions.php:

// remove unnecessary menus
function remove_admin_menus () {
global $menu;

// all users
$restrict = explode(‘,’, ‘Links,Comments’);

// non-administrator users
$restrict_user = explode(‘,’, ‘Media,Profile,Users,Tools,Settings’);

// WP localization
$f = create_function(‘$v,$i’, ‘return __($v);’);
array_walk($restrict, $f);
if (!current_user_can(‘activate_plugins’)) {
array_walk($restrict_user, $f);
$restrict = array_merge($restrict, $restrict_user);
}

// remove menus
end($menu);
while (prev($menu)) {
$k = key($menu);
$v = explode(‘ ‘, $menu[$k][0]);
if(in_array(is_null($v[0]) ? ” : $v[0] , $restrict)) unset($menu[$k]);
}

}
add_action(‘admin_menu’, ‘remove_admin_menus’);

Here, you should focus on setting variables listed below in the following way:

$restrict — This is a comma-delimited list comprising of menu items. These (including administrators) will not get displayed to users. Links and Comments have been hidden in the above stated example.

$restrict_user — This is a comma-delimited list that includes menu items that’s not displayed to non-administrators.

4. No Update Notifications

Although WordPress update notifications can be very useful to you, it may become a cause of worry for your users. So simply disable it in a plugin or functions.php file of the theme. Here’s how you can disable it:

// remove update notifications
<?php
function no_update_notification() {
if (!current_user_can(‘activate_plugins’)) remove_action(‘admin_notices’, ‘update_nag’, 3);
}
add_action(‘admin_notices’, ‘no_update_notification’, 1);

5. Remove the Administration Bar

WordPress displays a dark grey administration bar. This is available right at the top of live site once logged in. This is not beneficial. Hence, you may eliminate it by using PHP line in your plugin or the functions.php code:

// remove admin bar
add_filter(‘show_admin_bar’, ‘__return_false’);

6. Get Rid of Unnecessary Dashboard Widgets

Dashboard offers a confusing order of options to your users. So make sure you get rid of dashboard widgets. The plugin or functions.php code mentioned below will help you go about it:

// remove unnecessary dashboard widgets
function remove_dashboard_widgets(){

global $wp_meta_boxes;

// only remove “Right Now” for non-administrators
if (!current_user_can(‘activate_plugins’)) {
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_right_now’]);
}

// remove widgets for everyone
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_recent_comments’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_incoming_links’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]);

}
add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’);

You can configure this as per your requirements. The ID of dashboard widget is assigned to its div element. You need to place it in the HTML source. Another way is to use ‘Developer Tools’.

7. Eliminate Post Meta Boxes and Unnecessary Page

Only a very few people, including administrators need all options available to posts, pages, and custom posts. Screen Options can be used to hide these by using the menu at the top-right of the editing screen. However, it is possible for users to re-enable options. For deleting boxes permanently, simply add the following code to functions.php or a plugin:

// remove unnecessary page/post meta boxes
function remove_meta_boxes() {

// posts
remove_meta_box(‘postcustom’,’post’,’normal’);
remove_meta_box(‘trackbacksdiv’,’post’,’normal’);
remove_meta_box(‘commentstatusdiv’,’post’,’normal’);
remove_meta_box(‘commentsdiv’,’post’,’normal’);
remove_meta_box(‘categorydiv’,’post’,’normal’);
remove_meta_box(‘tagsdiv-post_tag’,’post’,’normal’);
remove_meta_box(‘slugdiv’,’post’,’normal’);
remove_meta_box(‘authordiv’,’post’,’normal’);

// pages
remove_meta_box(‘postcustom’,’page’,’normal’);
remove_meta_box(‘commentstatusdiv’,’page’,’normal’);
remove_meta_box(‘trackbacksdiv’,’page’,’normal’);
remove_meta_box(‘commentsdiv’,’page’,’normal’);
remove_meta_box(‘slugdiv’,’page’,’normal’);
remove_meta_box(‘authordiv’,’page’,’normal’);

}
add_action(‘admin_init’,’remove_meta_boxes’);

You need to add or remove the following lines as required:

‘remove_meta_box’

Place the ID assigned to the div element of Metabox in the HTML source. Developer Tools can also be used for the same.

Leave a Reply