SwiftModders Posted April 15, 2020 Share Posted April 15, 2020 (edited) Hi All, I am trying to grab the primary (and secondary) navbar for a logged-in user from within my module. I'm trying to pull the object so I can store it for later use. I'm able to grab the navbar for a non-logged in user easily, but for some reason, it's not changing when I set the session UID to a specific client ID and run navbar hooks. Example: $_SESSION['uid'] = 1; $primaryNavbar = Menu::primaryNavbar(); $secondaryNavbar = Menu::secondaryNavbar(); run_hook('ClientAreaPrimaryNavbar', $primaryNavbar); run_hook('ClientAreaSecondaryNavbar', $secondaryNavbar); If I try to return the $primaryNavbar, it returns the non-logged in user. Is there a better way to set the user ID and grab what the $primaryNavbar would look like? Edit: I forgot to mention that I am trying to pull this information into the admin-side of my module, not the client-side (frontend). Edited April 15, 2020 by SwiftModders LLC 0 Quote Link to comment Share on other sites More sharing options...
gbotica Posted April 15, 2020 Share Posted April 15, 2020 Hi there, Hopefully this will help you, here's how I do it in /includes/hooks/menu.php: use WHMCS\View\Menu\Item as MenuItem; /*---------- Navigation Menus ----------*/ add_hook('ClientAreaNavbars', 1, function () { // Get the current navigation bars. $primaryNavbar = Menu::primaryNavbar(); $secondaryNavbar = Menu::secondaryNavbar(); // Is client logged in? $client = Menu::context('client'); /*---------- logged in menu customisations ----------*/ if (!is_null($client)) { // your code here } }) 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.