christmas sale
40%
discount for lifetime!
See plans down arrow

WHMCS Menu Customization

TIP

Hooks allow an execution of your own code when events occur inside WHMCS. Lagom hooks do not interfere with other themes in any way.

Introduction

Create your own hook and add namespaces:

<?php
use WHMCS\View\Menu\Item as MenuItem;

WHMCS Navbar

Add Item

add_hook('ClientAreaNavbars', -1, function () {
    $primaryNavbar = Menu::primaryNavbar();
    $secondaryNavbar = Menu::secondaryNavbar();
    
    //add child to primary navbar
    $primaryNavbar->addChild('email-sales', array(
        'label' => 'Email our sales team',
        'uri' => '[email protected]',
        'order' => 5,
        'icon' => 'fa-gem lm lm-envelope',
    ));

    //add child to secondary navbar
    $secondaryNavbar->addChild('email-sales', array(
        'label' => 'Email our sales team',
        'uri' => '[email protected]',
        'order' => 5,
        'icon' => 'fa-gem lm lm-envelope',
    ));
}

Remove Item

add_hook('ClientAreaNavbars', -1, function () {
    $primaryNavbar = Menu::primaryNavbar();
    $secondaryNavbar = Menu::secondaryNavbar();
    
    //remove child from primary navbar
    if ($primaryNavbar && !is_null($primaryNavbar->getChild('Open Ticket'))) {
        $primaryNavbar->removeChild('Open Ticket');
    }

    //remove child from secondary navbar
    if ($secondaryNavbar && !is_null($secondaryNavbar->getChild('Open Ticket'))) {
        $secondaryNavbar->removeChild('Open Ticket');
    }
}

More information on how to customize your navbars is available at the WHMCS official documentation.

WHMCS Sidebars

Add Item

add_hook('ClientAreaSidebars', 1, function($vars) {  
    $primarySidebar = Menu::primarySidebar();
    $secondarySidebar = Menu::secondarySidebar();
    
    //add child to primary sidebar
    $primarySidebar->addChild('social-media', array(
        'label' => 'Social Media',
        'uri' => '#',
        'icon' => 'fas fa-thumbs-up',
    ));

    //add child to secondary sidebar   
    $secondarySidebar->addChild('social-media', array(
        'label' => 'Social Media',
        'uri' => '#',
        'icon' => 'fas fa-thumbs-up',
    )); 
}

Remove Item

add_hook('ClientAreaSidebars', 1, function($vars) {  
    $primarySidebar = Menu::primarySidebar();
    $secondarySidebar = Menu::secondarySidebar();
    
    //remove child from primary sidebar
    if ($primarySidebar && !is_null($primarySidebar->getChild('Client Contacts'))) {
        $primarySidebar->removeChild('Client Contacts');
    }

    //remove child from secondary sidebar
    if ($secondarySidebar && !is_null($secondarySidebar->getChild('Client Contacts'))) {
        $secondarySidebar->removeChild('Client Contacts');
    }
}

More information on how to customize your sidebars is available at the WHMCS official documentation.