How to customize the dashboard

Table of contents
The WordPress dashboard is fully customizable. It is not really useful to do it for yourself or for the website administrator. However, it is very useful when you give the keys to the site to editors or contributors who may not have the technical knowledge to handle a WordPress site.

Introduction

Making a WordPress dashboard simple and user-friendly promotes performance on one hand and security on the other. Nothing is more distracting than seeing all the possibilities offered by WordPress to manipulate the site. And nothing is more frustrating for the administrator than having to repair the damage caused by users logged into the site. By cleaning up the WordPress dashboard to its simplest form, it allows you to kill two birds with one stone. And all this, with almost no third-party plugins.

The Dashboard Welcome for Elementor plugin

The only plugin used on this site is a plugin to modify the “Welcome” panel of the dashboard. If the panel is not visible, you have to check the box in “screen options”, located at the top of the screen.

The “Dashboard Welcome for Elementor” plugin

Create the “Welcome” panel template with Elementor

While it is possible to create a template with Elementor and then configure DWE to display it in the dashboard, it is not possible to create a multilingual template (with Polylang, for example). You will have to find a way to use only one template for the different languages.

The solution chosen by this site is to create a section by language (in the same template), then to configure the dynamic condition of the section (created with the Dynamic Conditions plugin), with the code of the current language.

The Dynamic Conditions plugin
Dynamic Conditions settings for a section

Once the Elementor template is created, you should have two sections, one for each language. The image below shows the first section in French and the other in English. Both sections are stacked in the same template.

The two multilingual sections of the template

Configuration of the different panels

To configure the different panels, we will use a few lines of code, rather than installing an additional plugin.

  • Start by creating a PHP file, then follow the guide according to the features you want to modify.

Remove the metaboxes

The metaboxes are the information blocks that are located just below the Welcome panel. Below are the deleted blocks for users other than the administrator.

  • Try to see the effect of each command.
// Remove dashboard widgets
  function remove_widgets() {
    if (!current_user_can('administrator')) {
      remove_meta_box('dashboard_activity', 'dashboard', 'normal');
      remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
      remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
      remove_meta_box('e-dashboard-overview', 'dashboard', 'normal');
      remove_meta_box('dashboard_primary', 'dashboard', 'side');
      remove_meta_box('dashboard_secondary', 'dashboard', 'side');
      remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
      remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
      remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
      remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
    }
  }
  add_action('wp_dashboard_setup', 'remove_widgets');

Create a metabox

Yes, it is possible to create a metabox, to inform users, for example.

  • You must start by registering the metabox with the code below:
// Add a custom widget to dashboard
function register_custom_dashboard_widget() {
  wp_add_dashboard_widget ('custom_dashboard_widget', 'Infos from' . ' ' . get_bloginfo(), 'custom_dashboard_widget');
}
add_action('wp_dashboard_setup', 'register_custom_dashboard_widget');
  • then, fill the metabox with the desired information. Be careful, the code below is half HTML, hence the “<?php” and “?>”.
<?php
  function custom_dashboard_widget() {
?>
  <p>Aucune information</p>
<?php
}
?>

It is of course possible to do this for a multilingual site, created with Polylang. The title of the metabox, here “Infos from“, must be written in English in both languages, then translated with the “strings translations” panel of Polylang.

// Add a custom widget to dashboard
function register_custom_dashboard_widget() {
  if (function_exists('pll_current_language')) {
    if (pll_current_language() == "en") {
      wp_add_dashboard_widget(
        'custom_dashboard_widget',
        pll_translate_string('Infos from', 'en') . ' ' . get_bloginfo(),
        'custom_dashboard_widget'
      );
    } else {
      wp_add_dashboard_widget(
        'custom_dashboard_widget',
        pll_translate_string('Infos from', 'fr') . ' ' . get_bloginfo(),
        'custom_dashboard_widget'
      );
    }
  }
}
add_action('wp_dashboard_setup', 'register_custom_dashboard_widget');

Here, the texts are written in both languages, because it is easier to write one piece of information in HTML, rather than several in the Polylang panel. But, it is also possible to do it with Polylang.

<?php
  function custom_dashboard_widget() {
    if (function_exists('pll_current_language')) {
      if (pll_current_language() == "en") {
        ?>
          <p>No informations</p>
        <?php
      } else {
        ?>
          <p>Aucune informations</p>
        <?php
      }
    }
  }
?>

Remove options from the administration bar

There is no point in leaving an administration bar with features that are not useful to users.

// Remove options from admin bar
function remove_dashboard_adminbar_items() {
  if (!current_user_can('administrator')) {
    global $wp_admin_bar;
      
    // Remove the WordPress logo
    $wp_admin_bar->remove_menu('wp-logo');
    $wp_admin_bar->remove_menu('comments');
    $wp_admin_bar->remove_menu('new-content');
    $wp_admin_bar->remove_menu('updates');
  }
}
add_action('wp_before_admin_bar_render', 'remove_dashboard_adminbar_items');

Remove the sidebar items

Finally, it is also possible to delete the elements that make up the left sidebar.

// Remove Menu items 
function remove_dashboard_menu_items() {
  if (!current_user_can('administrator')) {
    remove_menu_page ('edit.php');
    remove_menu_page ('edit-comments.php');
    remove_menu_page ('edit.php?post_type=elementor_library');
    remove_menu_page ('tools.php');
  }
}
add_action('admin_menu','remove_dashboard_menu_items');

Here is what the administration console looks like for a contributor on this site. It is even possible to change the language.

The administration console of WordPress for the contributors of this site

The final word

Here is another demonstration that it is quite possible to create beautiful administration consoles with Elementor and a few lines of code, without using plugins.

Table of contents
Also to be consulted

Create an App for Azure (part 4)

Printing a PDF

Homepage

Customize the skin of an archive

Header and menus

Design of the website

The modal windows and the connection system

Running Javascript in WordPress

Generate a SQL query on WordPress

Create an App for Azure (part 2)

Also to be consulted

Basic settings for WordPress and Elementor

Creating custom fields

Running Javascript in WordPress

Homepage

Registration

To register, please fill in the fields below

Forgot your password ?

You will receive a message with a link allowing you to renew your password

Password update

Please enter your old password
as well as a new one and confirm it

Login