neaweb6 Posted December 11, 2016 Share Posted December 11, 2016 Hey guys, I am replacing all of the support links in WHMCS to direct to my Kayako system. I changed the navigation links on the client area using a custom hook from the WHMCS documentation. This worked fine and here's the hook file: <?php // Call client area menu use WHMCS\View\Menu\Item as MenuItem; // Changes the Support > Tickets child menu text and URL add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $navItem = $primaryNavbar->getChild('Support'); if (is_null($navItem)) { return; } $navItem = $navItem->getChild('Tickets'); if (is_null($navItem)) { return; } $navItem->setLabel('My Conversations'); $navItem->setUri('https://support.neawebservices.com/conversations'); }); // Changes the Open Ticket parent menu and url add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $navItem = $primaryNavbar->getChild('Open Ticket'); if (is_null($navItem)) { return; } $navItem->setLabel('Start a Conversation'); $navItem->setUri('https://support.neawebservices.com/conversation/new'); }); // Removes the Knowledgebase child menu from the Support parent menu add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Knowledgebase'); } }); ?> I followed the documentation to change the Support sidebar that shows up using the same method, but I am getting a 500 error after submitting the changes. Here's the hook I am using: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->getChild("Support") ->getChild("Support Ticket") ->setLabel("My Conversations"); }); ?> 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 11, 2016 Share Posted December 11, 2016 you need to check if the requested item is not NULL first before performing any actions <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild("Support"))){ if (!is_null($primarySidebar->getChild("Support")->getChild("Support Ticket"))){ $primarySidebar->getChild("Support") ->getChild("Support Ticket") ->setLabel("My Conversations"); } } }); 0 Quote Link to comment Share on other sites More sharing options...
neaweb6 Posted December 12, 2016 Author Share Posted December 12, 2016 you need to check if the requested item is not NULL first before performing any actions <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild("Support"))){ if (!is_null($primarySidebar->getChild("Support")->getChild("Support Ticket"))){ $primarySidebar->getChild("Support") ->getChild("Support Ticket") ->setLabel("My Conversations"); } } }); Thank you!! 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.