hostingarg Posted November 16, 2020 Share Posted November 16, 2020 Hi.I have a hook that generates a support pin for each client.This support pin is displayed on ClientAreaPrimarySidebar.I would like it to only be shown on the home page of the client area and not on all pages of the client area.How could I do this?The code (extracted from this same community) is the following: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context('client'); if (!is_null($client)) { $SupportPIN = generatePinCode($_SESSION['uid'], 8); $primarySidebar->addChild('Support-Pin', array( 'label' => "Pin de Soporte", 'uri' => '#', 'order' => '10', 'icon' => 'fa-ticket' )); //$primarySidebar->getChild('Support-Pin')->setBodyHtml($SupportPIN); } }); add_hook('AdminAreaClientSummaryPage', 1, function($vars) { return 'Support Pin: ' . generatePinCode($vars['userid'], 8); }); function generatePinCode($clientid = 0, $length = 6){ $clientid = intval($clientid); preg_match_all('!\d+!', md5(date("y" . $clientid)), $matches); $numbers = join("", $matches[0]); return substr($numbers, 0, $length); } Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 17, 2020 Share Posted November 17, 2020 15 hours ago, hostingarg said: The code (extracted from this same community) is the following: original code from the thread below... 15 hours ago, hostingarg said: I would like it to only be shown on the home page of the client area and not on all pages of the client area. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $templatefile = $smarty->getVariable('templatefile'); $client = Menu::context('client'); if (!is_null($client) && in_array($templatefile, array('clientareahome'))) { $SupportPIN = generatePinCode($_SESSION['uid'], 8); $primarySidebar->addChild('Support-Pin', array( 'label' => "Pin de Soporte", 'uri' => '#', 'order' => '10', 'icon' => 'fa-ticket' )); $primarySidebar->getChild('Support-Pin')->setBodyHtml($SupportPIN); } }); the second hook in the file would remain the same as that refers to the admin area. 1 Quote Link to comment Share on other sites More sharing options...
hostingarg Posted November 17, 2020 Author Share Posted November 17, 2020 1 hour ago, brian! said: original code from the thread below... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $templatefile = $smarty->getVariable('templatefile'); $client = Menu::context('client'); if (!is_null($client) && in_array($templatefile, array('clientareahome'))) { $SupportPIN = generatePinCode($_SESSION['uid'], 8); $primarySidebar->addChild('Support-Pin', array( 'label' => "Pin de Soporte", 'uri' => '#', 'order' => '10', 'icon' => 'fa-ticket' )); $primarySidebar->getChild('Support-Pin')->setBodyHtml($SupportPIN); } }); the second hook in the file would remain the same as that refers to the admin area. @brian! Thanks a lot! You are a master. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.