acmjosh Posted February 2, 2019 Share Posted February 2, 2019 Hello, I'm trying to figure out the hook system and want to do a simple hook for when a user is logged in to display a menu I have done something like this obviously it doesn't work - the standard add menu hook displays to both logged in and logged out. add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if ($ca->isLoggedIn()) { $primaryNavbar->addChild('Page Name') ->setUri('pagename') ->setOrder(10); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 3, 2019 Share Posted February 3, 2019 On 02/02/2019 at 09:43, acmjosh said: I'm trying to figure out the hook system and want to do a simple hook for when a user is logged in to display a menu I have done something like this obviously it doesn't work - the standard add menu hook displays to both logged in and logged out. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if ($client) { $primaryNavbar->addChild('Page Name')->setURI('filename.php')->setOrder(10); } }); 0 Quote Link to comment Share on other sites More sharing options...
acmjosh Posted February 3, 2019 Author Share Posted February 3, 2019 Thanks Brian you are very fast responding that makes sense - I'll give that one a go. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.