hobartimus Posted May 1 Share Posted May 1 I want to remove the Knowledgebase and Downloads menu items from the client area. I used the webhook for the main nav as described here and it worked fine. However, trying to use these instructions for the sidebar is not working at all. This is my code: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Downloads'); } }); add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->getChild('Support') ->removeChild('Knowledgebase'); $primarySidebar->getChild('Support') ->removeChild('Downloads'); }); 0 Quote Link to comment Share on other sites More sharing options...
SimpleSonic Posted May 2 Share Posted May 2 This is what you need: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $secondarySidebar->getChild('Support') ->removeChild('Knowledgebase') ->removeChild('Downloads'); }); 0 Quote Link to comment Share on other sites More sharing options...
hobartimus Posted May 2 Author Share Posted May 2 Thank you, but I've tried that and I get this when trying to access the site: Oops! Something went wrong and we couldn't process your request. Please go back to the previous page and try again. 0 Quote Link to comment Share on other sites More sharing options...
SimpleSonic Posted May 2 Share Posted May 2 I've tested the hook prior to sharing the code, so there seems to be an issue with your implementation. 0 Quote Link to comment Share on other sites More sharing options...
hobartimus Posted May 2 Author Share Posted May 2 I don't know. I have the file located here… /includes/hooks/remove-items.php And this is the entire code… <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $secondarySidebar->getChild('Support') ->removeChild('Knowledgebase') ->removeChild('Downloads'); }); But, this code works fine for the main nav… <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Downloads'); } }); 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted May 2 Share Posted May 2 1 hour ago, SimpleSonic said: I've tested the hook prior to sharing the code, so there seems to be an issue with your implementation. It's not. On many pages, there's no support sidebar. Trying to access it will throw an exception. This should work. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if(!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support') ->removeChild('Knowledgebase') ->removeChild('Downloads'); } }); 0 Quote Link to comment Share on other sites More sharing options...
hobartimus Posted May 2 Author Share Posted May 2 That works! Thank you so much. 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.