irh Posted April 26, 2017 Share Posted April 26, 2017 I need to alter the sidebar to remove login to cPanel/webmail links for specific product group. I have implemented a custom hook as advised in the documentation, which does this unconditionally: add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $serviceDetails = $primarySidebar->getChild("Service Details Actions"); if (empty($serviceDetails)) { return; } $service_ids = [33]; $serviceDetailsChildren = $serviceDetails->getChildren(); $keysToUnset = ['Change Password', 'Login to cPanel', 'Login to Webmail']; foreach($serviceDetailsChildren as $key => $service_details_child) { if (in_array($key, $keysToUnset)) { $serviceDetails->removeChild($key); } } }); However, I cannot find a way to determine product/service (or even better - service group) based on the `id` query string. Any help? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 26, 2017 Share Posted April 26, 2017 there would be a few ways to get the product ID - one of which would be to use the Class documentation... so if we modified your hook to use that... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $serviceDetails = $primarySidebar->getChild("Service Details Actions"); if (empty($serviceDetails)) { return; } $service = Menu::context('service'); $pid = $service->packageId; $gid = $service->product->productGroupId; if ($gid == '10') { $serviceDetailsChildren = $serviceDetails->getChildren(); $keysToUnset = ['Change Password', 'Login to cPanel', 'Login to Webmail']; foreach($serviceDetailsChildren as $key => $service_details_child) { if (in_array($key, $keysToUnset)) { $serviceDetails->removeChild($key); } } } }); that will then give you access to 2 variables - $pid and $gid - then it should just be a case of modifying the if statement to check for specific products or productgroups (or an array of them)... 1 Quote Link to comment Share on other sites More sharing options...
irh Posted April 27, 2017 Author Share Posted April 27, 2017 Perfect, thank you. This is what I was mising - $service = Menu::context('service'); 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.