Jump to content

hook - can not hide menu entry


cluster

Recommended Posts

Is this also working with Top menu?

 

and how can I hide f.ex. the domain register from sidemenu?

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Domains'))) {
                $primarySidebar->getChild('Domains')
                                          ->removeChild('Register a New Domain');
   }

}); 

Link to comment
Share on other sites

solved - the sidebar or topbar name is important ...

 

- ClientAreaPrimaryNavbar

- ClientAreaPrimarySidebar

- ClientAreaSecondarySidebar

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Client Shortcuts'))) {
                $primarySidebar->getChild('Client Shortcuts')
                                          ->removeChild('Order New Services');
   }

}); 

Link to comment
Share on other sites

if you are in the client area homepage and wanted to remove both the navbar link to register a domain, and the equivalent sidebar link, you could use the following code...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Domains'))) {
       $primaryNavbar->getChild('Domains')
           ->removeChild('Register a New Domain');
   }
});

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
   if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
            $secondarySidebar->getChild('Client Shortcuts')
                           ->removeChild('Register New Domain');
   }
});

I don't think in this instance you need to check that the client is logged in, but it would be simple enough to add if you ran into issues with it.

 

also, you'll need to work through the client area because there are additional sidebar links to register a domain that you'll need to add more hooks to remove.

 

the Cheatsheets in the v6 documentation - http://docs.whmcs.com/Version_6.0 - will be useful in guiding you through, but some of their code isn't quite right... so if you can find an example of what you want to do here in the forum, with code posted by myself or sentq (we've both posted numerous nav/sidebar hooks), trust that rather than the documentation code! :idea:

Link to comment
Share on other sites

if you want to get rid of the whole sidebar (parent) and not a child, use the following...

 

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
   if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
            $secondarySidebar->removeChild('Client Shortcuts');
   }
});

Link to comment
Share on other sites

sorry, I meant the domain search box on client area home (clientareahome.tpl)

a screenshot is always useful to make sure we're talking about the same thing... :)

 

if you mean the green homepage panel box, the following hook will remove it..

 

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

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
{
$homePagePanels->removeChild('Register a New Domain');
});

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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