Jump to content

How to delete menu item?


Persemp

Recommended Posts

Dear community,

I am new on this forum. Since a month I have been trying to configure the WHMCS installation for my needs. WHMCS hotline has directed me to this forum.

Can someone from the community help me, who has already experienced with WHMCS ?
I want to remove from the menu ,,Announcements,, and ,,Network Status,,. I found this code (below) to copy in a hook.
The question: in which hook do I have to copy this code? Do I have to create a new hook? If so, with what name?

Thank you for help.

Best regards:

Persemp

Hiding/Removing a Menu Item

You can remove a menu item as follows:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Network Status'))) {
        $primaryNavbar->removeChild('Network Status');
    }
});

 

Link to comment
Share on other sites

Welcome to the WHMCS community :)

you need to create new .php file inside /includes/hooks/ directory, the file name could be anything, lets call it RemoveNavbarAnnouncementsStatus.php

then copy the following lines inside it, it should remove both links from Primary Navbar:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Announcements'))) {
        $primaryNavbar->removeChild('Announcements');
    }
  	if (!is_null($primaryNavbar->getChild('Network Status'))) {
        $primaryNavbar->removeChild('Network Status');
    }
});

 

Link to comment
Share on other sites

1. Create a new php file in the /includes/hooks folder. You can name it whatever you want (e.g. remove_menu_items.php)

2. Copy and paste this code:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

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

3. Save and refresh your page.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated