Step-by-Step Guide to Removing Menu Items in WHMCS: Optimize Your User Interface

In the following article, I will outline:

  • How to remove the “Store” button from WHMCS
  • How to remove the “Knowledgebase” button from WHMCS
  • How to remove the “Announcements” button from WHMCS
  • How to remove the “Network Status” button from WHMCS
  • How to remove the “Contact Us” button from WHMCS

After implementing this update, only the “Home” and “My Account” options will appear in your WHMCS menu.

1. How to Create a New WHMCS Hook for Web UI Menu Modifications

When you’re looking to modify the Web User Interface (UI), the common method is to adjust the .tpl files within your WHMCS template directory. However, when it comes to removing specific menu items from WHMCS, you’ll need a different approach: creating a new WHMCS Hook.

In this guide, I’ll walk you through the steps of creating a new file, which we’ll name menu.php, and placing it in your includes/hooks directory.

2. Inserting Custom Hook Code into Your WHMCS menu.php File

Once you’ve set up your new menu.php file in the includes/hooks directory, the next step is to populate it with the following code:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

   if (!is_null($primaryNavbar->getChild('Store'))) {
       $primaryNavbar->removeChild('Store');
   }

   if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
       $primaryNavbar->removeChild('Knowledgebase');
   }

   if (!is_null($primaryNavbar->getChild('Announcements'))) {
       $primaryNavbar->removeChild('Announcements');
   }

   if (!is_null($primaryNavbar->getChild('Network Status'))) {
       $primaryNavbar->removeChild('Network Status');
   }

   if (!is_null($primaryNavbar->getChild('Contact Us'))) {
       $primaryNavbar->removeChild('Contact Us');
   }

});

3. Customize Menu Items by Editing the Hook Code

If you want to keep a specific menu item intact while removing others, you can simply comment out or remove the corresponding section of code from the provided code snippet.

For instance, if you wish to retain the “Store” option in the menu, simply locate and remove or comment out the relevant lines of code dedicated to the “Store” section.

   if (!is_null($primaryNavbar->getChild('Store'))) {
       $primaryNavbar->removeChild('Store');
   }

By following these steps, you’ll effectively tailor your WHMCS Web UI to meet your specific needs. Enjoy!

Was this tutorial useful? Buy me a drink by using the “Donate” button below. :)

Leave a Comment

Your email address will not be published. Required fields are marked *