hardbrasil Posted February 9, 2016 Share Posted February 9, 2016 (edited) hello fellas, i am trying to remove some sidebars and without success. i am using this code that support told me but i got an error on aplication <?php use WHMCS\View\Menu\Item as MenuItem; if (!is_null($primarySidebar->getChild('Client Shortcuts'))) { add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->removeChild('Client Shortcuts'); } ); please see wich one i went to remove txk advanced Edited February 9, 2016 by hardbrasil 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 9, 2016 Share Posted February 9, 2016 the contacts and client shortcuts can be removed using the method in the thread below... http://forum.whmcs.com/showthread.php?111163-Hook-to-remove-Contacts-Sub-Accounts&p=452734#post452734 the Recent News panel can also be removed in the same file... so create a .php file in includes/hooks, give it a filename and add the following code to it... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Client Contacts'))) { $secondarySidebar->removeChild('Client Contacts'); } if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) { $secondarySidebar->removeChild('Client Shortcuts'); } }); add_hook('ClientAreaHomepagePanels', 1, function (MenuItem $homePagePanels) { if (!is_null($homePagePanels->getChild('Recent News'))) { $homePagePanels->removeChild('Recent News'); } }); 1 Quote Link to comment Share on other sites More sharing options...
hardbrasil Posted February 9, 2016 Author Share Posted February 9, 2016 Thank you so much! works! 0 Quote Link to comment Share on other sites More sharing options...
hardbrasil Posted February 9, 2016 Author Share Posted February 9, 2016 Hi Brian, i create this hook using your sintax to remove a especific item of sidebar menu, actually works, but when i change page i got an error, this is the code <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->getChild('My Account') ->removeChild('Contacts/Sub-Accounts'); }); the error is: Fatal error: Call to a member function removeChild() on null in /var/www/vhosts/gleads.com.br/fin.gleads.com.br/includes/hooks/remove_item_sidebar.php on line 8 thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 9, 2016 Share Posted February 9, 2016 Hi, you need to check that what you want to remove exists *before* you try to remove it - otherwise, it will work fine on pages where it exists, but cause an error when it doesn't. so, try using... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('My Account'))) { $primarySidebar->removeChild('Contacts/Sub-Accounts'); } }); 0 Quote Link to comment Share on other sites More sharing options...
hardbrasil Posted February 9, 2016 Author Share Posted February 9, 2016 thanks again! 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.