xxxmicrobexxx Posted July 28, 2015 Share Posted July 28, 2015 V6.01 I have a hook menu.php It is working to do what I wanted, add an item to the support menu and remove the downloads item. Cool! But when logging out from the client area it throws an error. "Fatal error: Call to a member function addChild() on a non-object in /home/steved/public_html/includes/hooks/menu.php on line 9" This implies that when someone is logging out and logout.php is being loaded, it is calling the menu hook. Reloading logout.php then redirects to index.php When logout.php is being called, by that time the $ca->isLoggedIn() flag should be false shouldn't it? So it shouldn't even see the code throwing the error. Or am I completely missing the point somewhere? $ca = new WHMCS_ClientArea(); use WHMCS\View\Menu\Item as MenuItem; if ($ca->isLoggedIn()) { add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar){ /** Add Create Ticket to the Support Menu **/ $primaryNavbar->getChild('Support')->addChild('Firewall Management', array( 'label' => 'Open a Ticket', 'uri' => 'https://domain.com/submitticket.php', 'order' => '1', )); }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Downloads'); } }); } 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted July 29, 2015 Share Posted July 29, 2015 this come from custom page: $ca = new WHMCS_ClientArea(); $ca->isLoggedIn(); and the rest is action hook related, your code can be something like this: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar){ if (isset($_SESSION['uid'])){ /** Add Create Ticket to the Support Menu **/ $primaryNavbar->getChild('Support')->addChild('Firewall Management', array( 'label' => 'Open a Ticket', 'uri' => 'https://domain.com/submitticket.php', 'order' => '1', )); } }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Downloads'); } }); 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.