How to Give Clients Access to Their Dashboard

The Client Dashboard is a page like any other, so you can link to it just as you would link to any other page, anywhere on your site, in emails, etc.

For starters, you will probably want to add the Client Dashboard to one of your nav menus.

Add the Client Dashboard to a Menu

The easiest way to give your clients access to their dashboard is to add the link to your menu. When logged into WordPress, click Customize in the menu bar.

Then click on Menus and select the menu you want to add the Client Dashboard to. Click the Add Items button, and you should be able to find your client dashboard under Pages.

By default, your client dashboard is called “Client Dashboard.” You can change the name by editing the page title, or choose another page for your dashboard (and give it any name you like).

Add that page to your menu, and when clients click visit the page they will be prompted to log in.

Existing Users (Adding Roles)

If you have existing WordPress users that you want to add as a client, just add a new client as usual, under Clients / Add New. If Client Power Tools finds an existing user with the same email address, it will update that user rather than creating a new one.

Add to the Knowledge Base

The knowledge base is made up of normal WordPress pages, and Client Power Tools restricts them to clients. When you first activate Client Power Tools, it creates a page for the knowledge base. You can find it under the Pages menu in your WordPress dashboard.

Changing the page title will change the name of your knowledge base. You can expand your knowledge base by adding child pages. To do that, just create a new page and look for the Page Attributes widget in the sidebar. Under Parent Page, select your knowledge base page.

You can, of course, create child pages of child pages. Whatever you create will show up in the drop-down index on your client dashboard.

Also, the index respects the Order field. All the child pages of the same level will be displayed in the index starting with the lowest number.

Customize the Appearance

Client Power Tools is designed to be as “transparent” as possible. For the most part it will inherit your theme styles and adds very little styling of its own. But if you do need to override Client Power Tools styles, you can use .customize-cpt before your CSS selectors.

Shortcodes

[status-update-request-button] Use this shortcode anywhere on your website to show the Request Status Update button to logged-in clients.

Filter Hooks

For general information about using filters hooks, see the WordPress documentation. Client Power Tools supports one filter as of 1.5.5.

cpt_custom_fields

The cpt_custom_fields filter expects a returned array with the following key-value pairs:

  • id (string, required). A slug that will be used to identity the field in the form and the database.
  • label (string, required). The public label for the form field.
  • required (boolean, optional). True or false. Whether the field is required in the form.
  • type (string, required). The html input type (text, email, url, number, etc.).

Here is an example of how I use it to add a field for a client’s website login URL. (Both of the following code examples can go in your theme’s functions.php file.)

function add_custom_fields($fields) {
  $fields[] = [
    'id' => 'clients_login_url',
    'label' => __('Client\'s Login URL', 'client-power-tools'),
    'required' => false,
    'type' => 'url',
  ];
  return $fields;
}
add_filter('cpt_custom_fields', 'add_custom_fields');

This adds a Client’s Login URL field to the form for adding or editing a client:

If you enter a URL and add or update a client, it will be saved to the database. I also created a shortcode so I can add a Log in to Your Website button to the client dashboard. Here is my code for that:

function client_login_shortcode() {
  $clients_user_id = get_current_user_id();
  if (!$clients_user_id) return;
  $clients_login_url = get_user_meta($clients_user_id, 'cpt_clients_login_url', true);
  if (!$clients_login_url) return;
  ob_start();
    ?>
      <p><a href="<?php echo $clients_login_url; ?>" class="button" target="_blank"><?php _e('Log in to Your Website', 'cpt-theme-child'); ?></a></p>
    <?php
  return ob_get_clean();
}
add_shortcode('client-login', 'client_login_shortcode');

I added the [client-login] shortcode to my client dashboard page, which results in this:

And now my clients can easily get to their websites.