kenchiro Posted April 7, 2016 Share Posted April 7, 2016 How to Change menu Navbar in whmcs when client not login, Now i can change menu navbar when client login but i do not know how to change navbar when client not login. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 7, 2016 Share Posted April 7, 2016 it's basically a similar way - as you know, when you want to remove a navbar item (e.g "Home") for a client who IS logged in, you would do this... use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (!is_null($client) and (!is_null($primaryNavbar->getChild('Home')))) { $primaryNavbar->removeChild('Home'); } }); now if you want to remove the "Home" navbar item when the client is NOT logged in, you would do the following... use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (is_null($client) and (!is_null($primaryNavbar->getChild('Home')))) { $primaryNavbar->removeChild('Home'); } }); note that the only difference between the two is the ! before is_null($client) - the first hook checks to see if the client is logged in; the second checks to see that they are not. when you become familiar with the navbars, there is a simpler way to modify most of them as they will only exist in one navbar and not both (logged in and not logged in)... e.g when not logged in (as in your screenshot), there is a navbar item called "Announcements" - if you want to remove it, you can use... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Announcements'))) { $primaryNavbar->removeChild('Announcements'); } }); note that we aren't checking whether the client is logged in or not - we don't need to - the "Announcements" navbar item only exists with that name in the not logged in navbar; there is an "Announcements" link in the navbar when logged in, but it's a child of "Support" and so would require another hook to remove it - in short, the above code removes the "Announcements" link from the non-client navbar, but doesn't affect the link in the client navbar. however, until you are familiar with the navbars, it's probably safer for you to check, in the hook, whether the client is logged in or not. 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.