rickybsb Posted January 7, 2019 Share Posted January 7, 2019 Hi experts, i´m trying to add item to primary menu, but didn´t show code <?php #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($client)) { $primaryNavbar->addChild('UnBlock IP') ->setUri('index.php?m=unblockip') ->setOrder(70); } }); but when i use without restriction, thus not requiring user to be athenticated, it works <?php #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('UnBlock IP') ->setUri('index.php?m=unblockip') ->setOrder(70); }); what am i doing wrong? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 8, 2019 Share Posted January 8, 2019 On 07/01/2019 at 19:08, rickybsb said: what am i doing wrong? the problem with the first hook is that you're checking the status of $client, but never defining what $client is - so that if statement is never valid and hence the link is not added. <?php #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (!is_null($client)) { $primaryNavbar->addChild('UnBlock IP') ->setUri('index.php?m=unblockip') ->setOrder(70); } }); the above will add a menu link to a client's menu when they are logged in - if they are not logged in, the link will not be added. 1 Quote Link to comment Share on other sites More sharing options...
rickybsb Posted January 8, 2019 Author Share Posted January 8, 2019 5 hours ago, brian! said: the problem with the first hook is that you're checking the $status of $client, but never defining what $client is - so that if statement is never valid and so the link is not added. <?php #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (!is_null($client)) { $primaryNavbar->addChild('UnBlock IP') ->setUri('index.php?m=unblockip') ->setOrder(70); } }); the above will add a menu link to a client's menu when they are logged in - if they are not logged in, the link will not be added. worked like a charm thanks, man!!! 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.