Jump to content

Menu hook for logged in user


acmjosh

Recommended Posts

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);
   }
});

 

Link to comment
Share on other sites

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);
	}
});

 

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