John Posted November 12, 2017 Share Posted November 12, 2017 I am trying to remove the "Private Nameservers" sidebar menu item in domain management, but it don't seem to work. I try the following code and I get the dreaded OOPS message indicating a crash. add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $primarySidebar->getChild('Domain Details Management') ->removeChild('Manage Private Nameservers'); }); I ended up temporarily hiding it with CSS: #Primary_Sidebar-Domain_Details_Management-Manage_Private_Nameservers { display: none; } But I would prefer to do this with a hook. Any help would be appreciated. Link to comment Share on other sites More sharing options...
brian! Posted November 13, 2017 Share Posted November 13, 2017 <?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('Manage Private Nameservers'); } }); where you were going wrong is that you first need to check that the sidebar/child you want to remove exists, and only if it exists, can you then remove or change it... your hook code will run on every client page, and on any page that shows the "Private Nameservers" child, it will work fine; but on any page where that child doesn't exist, you'll get the oops message... because you're telling WHMCS to remove something that doesn't exist. Link to comment Share on other sites More sharing options...
Recommended Posts