mvmoay
mvmoay

Reputation: 1625

How to change the displayed customer name in WHMCS clientarea?

I got a working WHMCS setup. I think, that I basically know what I'm doing (did several addons, all work great) but there is one thing I was not able to solve yet.

Let's imagine a client of mine, called John Doe. In the clientarea, is says 'Welcome back, John!'. How can I change this? I want it to display 'Welcome back, John Doe'. Also, at the top right (with the Six theme), the user settings are displayed with the first name only.

How can I change the way that WHMCS displays the customer's name in the clientarea?

Upvotes: 2

Views: 1089

Answers (1)

mvmoay
mvmoay

Reputation: 1625

Wow, no response from WHMCS team... maybe they don't even now how to do this themselves... ;-)

Anyways, I found the ways to to this. In order to replace both the "Welcome back" page title and the menu heading, you will need two hooks.

Use this hook to replace the menu title of the dropdown (top right with "six" template):

<?php
use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
    $secondaryNavbar->getChild('Account')->setLabel('My account'); // Or whatever you like
});

The other one is trickier, because the customers name is not editable from within the template files. You also need a hook for this one:

<?php
use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPage', 1, function ($vars)
{
    if($vars['templatefile'] == 'clientareahome'){
        $vars['displayTitle'] = 'Welcome back!';
    }
    // If you want to use client's details, use $vars['clientsdetails']
    return $vars;
});

Good luck!

Upvotes: 2

Related Questions