alterman Posted January 4, 2018 Share Posted January 4, 2018 Hello Guys, I need to hide some options in the Manage Domain section from our clients (screen attached). Could you please assist me and let me know which hooks should I use? Thanks in advance! Link to comment Share on other sites More sharing options...
sentq Posted January 4, 2018 Share Posted January 4, 2018 this documentation show you how to find specific sidebar items and how to remove them https://developers.whmcs.com/themes/sidebars/#hiding-removing-a-sidebar-menu-item Link to comment Share on other sites More sharing options...
alterman Posted January 5, 2018 Author Share Posted January 5, 2018 (edited) @sentq Thanks, I've setup the following hook: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->getChild('Domains') ->removeChild('Auto Renew'); }); However, I'm getting "Ooops " error on the client are page. Could you please let me know if there anything wrong in my code? Thanks! Edited January 5, 2018 by WHMCS ChrisD Added code to code box, please remember to use this in the future Link to comment Share on other sites More sharing options...
sentq Posted January 5, 2018 Share Posted January 5, 2018 7 hours ago, alterman said: However, I'm getting "Ooops " error on the client are page. Could you please let me know if there anything wrong in my code? you will always need to check if the sidebar/navbar item exists before apply any changes or remove it, the following code just do that 1) check if the item we'r looking for exists then remove it: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Domains'))){ if (is_null($primarySidebar->getChild('Domains')->getChild('Auto Renew'))){ $primarySidebar->getChild('Domains')->removeChild('Auto Renew'); } } }); Link to comment Share on other sites More sharing options...
alterman Posted January 5, 2018 Author Share Posted January 5, 2018 @sentq Thanks, I've modified it a bit and it works like a charm. I hope someone finds it useful: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Domain Details Management'))) { $primarySidebar->getChild('Domain Details Management') ->removeChild('Auto Renew Settings') ->removeChild('Registrar Lock Status') ->removeChild('Domain Addons') ->removeChild('Domain Contacts') ->removeChild('Manage Private Nameservers'); } }); Link to comment Share on other sites More sharing options...
sentq Posted January 6, 2018 Share Posted January 6, 2018 any of the child items could be removed by other hook causing 500 error, we need to check if each of the child items exists before remove <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Domain Details Management'))) { if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Auto Renew Settings'))){ $primarySidebar->getChild('Domain Details Management')->removeChild('Auto Renew Settings'); } if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Registrar Lock Status'))){ $primarySidebar->getChild('Domain Details Management')->removeChild('Registrar Lock Status'); } if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Domain Addons'))){ $primarySidebar->getChild('Domain Details Management')->removeChild('Domain Addons'); } if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Domain Contacts'))){ $primarySidebar->getChild('Domain Details Management')->removeChild('Domain Contacts'); } if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Manage Private Nameservers'))){ $primarySidebar->getChild('Domain Details Management')->removeChild('Manage Private Nameservers'); } } }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts