I ran into an issue with this hook today - it works fine on a product linked to cPanel, but with other products it shows a blank page.
with the assistance of sentq, I was able to tweak it to work correctly.
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
$service = Menu::context('service');
$domain = $service->domain;
$servertype = $service->product->servertype;
# Not cPanel, no links added
if ($servertype!="cpanel"){
return;
}
if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
$primarySidebar->getChild('Service Details Actions')
->getChild('Login to cPanel')
->setUri('http://'.$domain.'/cpanel');
$primarySidebar->getChild('Service Details Actions')
->getChild('Login to Webmail')
->setUri('http://'.$domain.'/webmail');
}
});