Remove a Sidebar Item
You can customize the Client Area’s sidebar navigation menus through hooks and custom modules.
For more information, see Client Area Sidebars and our Developer Documentation.
Remove a Sidebar Menu Item
You can remove a menu item using the following example code:
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) {
if (!is_null($primarySidebar->getChild('My Account')) && !is_null($primarySidebar->getChild('My Account')->getChild('Billing Information'))) {
$primarySidebar->getChild('My Account')->removeChild('Billing Information');
}
});
Conditionally Remove a Sidebar Menu Item
You can manipulate a sidebar menu item by name with the ClientAreaSidebars
hook point.
The following example code checks which sidebar the element belongs to and then removes it:
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSidebars', 1, function() {
$primarySidebar = Menu::primarySidebar();
$secondarySidebar = Menu::secondarySidebar();
$id = 'Client Contacts';
if ($primarySidebar && !is_null($primarySidebar->getChild($id))) {
$objectToWorkWith = $primarySidebar->removeChild($id);
} elseif ($secondarySidebar && !is_null($secondarySidebar->getChild($id))) {
$objectToWorkWith = $secondarySidebar->removeChild($id);
}
if ($objectToWorkWith) {
$objectToWorkWith->removeChild($id);
}
});
Last modified: November 12, 2024