Hi, community! 🙂
I have a questions about hooks. So, I've been using some hooks to "hide" some menu/submenu items and sidebars in client area. I added all the hooks in one file (example: custom_hooks.php) and placed in /includes/hooks directory. And that works fine for some time and then it's simply stop working and all menus/submenus and sidebars reappear again.
I also tried to create separate .php file for each hook and upload it to the same location. Issue is the same: it stops working and all the elements reappear in client area.
Here's an example of the code used:
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
$secondarySidebar->removeChild('Choose Currency');
});
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
$secondarySidebar->removeChild('Actions');
});
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
$secondarySidebar->removeChild('Client Shortcuts');
});
add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) {
$primarySidebar->removeChild('My Invoices Summary');
});
add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) {
$primarySidebar->removeChild('My Invoices Status Filter');
});
add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
$secondarySidebar->removeChild('Billing');
});
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
if (!is_null($primaryNavbar->getChild('Support'))) {
$primaryNavbar->getChild('Support')->removeChild('Downloads');
}
});
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
if (!is_null($primaryNavbar->getChild('Support'))) {
$primaryNavbar->getChild('Support')->removeChild('Network Status');
}
});
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
if (!is_null($primaryNavbar->getChild('Billing'))) {
$primaryNavbar->getChild('Billing')->removeChild('My Quotes');
}
});
Is this wrong or issue is something else?
Thanks for your help!