In WHMCS v5, there was an area of the template where ‘service information’ was shown. I’m referring to the username, server, domain, etc. With the v6 template, this disappeared. Using this action hook, you can return the WHMCS service information display to your clients. Take a look. As always, if you have questions, please do contact us. If you want something custom developed, or customized, again, please do contact us. We’re absolutely here and ready to help however we can.

The problem:

Sometimes, clients just need a reminder of what their password is, what their server, or username is. It’s natural. This is why this information was originally provided in v5. Unfortunately, it was removed from the secondary sidebar in v6.

The solution:

This hook will return the WHMCS service information display to the sidebar in v6, but ONLY if the client is on a page where it should be shown. This will show the following information

  1. Username
  2. Password
  3. Domain
  4. IP Address
  5. Hostname
  6. NS1
  7. NS2

This provides a greater WHMCS service information display than was done in v5.

 

Usage:

Simply copy and paste the following code into a php file in your includes/hooks directory:

<?php
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

/* Add credentials to the end of all secondary sidebars. */
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
/* Get the credentials. */
$service = Menu::context('service');
$username = "{$service->username}";
$serverid = "{$service->server}";
$domain = "{$service->domain}";
$password = "{$service->password}";
$server = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('hostname');
$ipaddress = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('ipaddress');
$name1 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver1');
$name2 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver2');

$password = decrypt($password);
/* If the username isn't empty let's show them! */
if ($username != '') {
/*
Add a panel to the end of the secondary sidebar for credentials.
Declare it with the name "credentials" so we can easily retrieve it
later.
*/
$secondarySidebar->addChild('credentials', array(
'label' => 'Service Information',
'uri' => '#',
'icon' => 'fa-desktop',
));
/* Retrieve the panel we just created. */
$credentialPanel = $secondarySidebar->getChild('credentials');
$credentialPanel->moveToBack();
/* Show the username. */
$credentialPanel->addChild('username', array(
'label' => $username,
'order' => 1,
'icon' => 'fa-user',
));

/* Show the password. */
$credentialPanel->addChild('password', array(
'label' => $password,
'order' => 2,
'icon' => 'fa-lock',
));
/* Show the password. */
$credentialPanel->addChild('domain', array(
'label' => $domain,
'order' => 3,
'icon' => 'fa-globe',
));
/*show the server IP*/
$credentialPanel->addChild('ip', array(
'label' => $ipaddress,
'order' => 4,
'icon' => 'fa-info',
));
/*show the server name*/
$credentialPanel->addChild('server', array(
'label' => $server,
'order' => 5,
'icon' => 'fa-server',
));

/*NS1*/
$credentialPanel->addChild('name1', array(
'label' => $name1,
'order' => 6,
'icon' => 'fa-info-circle',
));
/*NS2*/
$credentialPanel->addChild('name2', array(
'label' => $name2,
'order' => 7,
'icon' => 'fa-info-circle',
));
}
});

Now, take a look at your client’s service page. You should see an additional sidebar with this WHMCS service information display. See below

serviceinfo