Jump to content

Hooks and Private in Knowledgebase


Recommended Posts

I set the following code in /includes/hooks/.

 

addSidebar.php

<?php

use WHMCS\View\Menu\Item as MenuItem;

 

add_hook('ClientAreaSecondarySidebar', 2, function(MenuItem $secondarySidebar) {

$secondarySidebar->getChild('Support')

->removeChild('Network Status');

});

 

And if I check Private in Knowledgebase, I meet the following error.

Fatal error: Call to a member function removeChild() on null in /WHMCS/includes/hooks/addSidebar.php on line 6

 

Please tell me how to resolve.

Link to comment
Share on other sites

I change addSidebar.php as the following.

But if I check Private in Knowledgebase, I meet the following error.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

if (App::getCurrentFilename() == 'supporttickets') {

add_hook('ClientAreaSecondarySidebar', 2, function(MenuItem $secondarySidebar)

{

$secondarySidebar->getChild('Support')

->removeChild('Network Status');

});

}

if (App::getCurrentFilename() == 'announcements') {

add_hook('ClientAreaSecondarySidebar', 2, function(MenuItem $secondarySidebar)

{

$secondarySidebar->getChild('Support')

->removeChild('Network Status');

});

}

if (App::getCurrentFilename() == 'knowledgebase') {

add_hook('ClientAreaSecondarySidebar', 2, function(MenuItem $secondarySidebar)

{

$secondarySidebar->getChild('Support')

->removeChild('Network Status');

});

}

Link to comment
Share on other sites

change addSidebar.php content to:

 

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

add_hook('ClientAreaSecondarySidebar', 2, function(MenuItem $secondarySidebar){
   if (!is_null($secondarySidebar->getChild('Support'))){
       if (!is_null($secondarySidebar->getChild('Support')->getChild('Network Status'))){
           $secondarySidebar->getChild('Support')->removeChild('Network Status');
       }
   }
});

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