Jump to content

ow do i hide menu item i created when user is logged in


tsupan

Recommended Posts

I created the below to add "Our Services" to the primary menu.

Question: how do i hide this menu item when user is logged in ?

 

 

 

<?php

add_hook('ClientAreaNavbars', 1, function ()


{



   // Get the current navigation bars.
   $primaryNavbar = Menu::primaryNavbar();



{
    // Save the "Contact Us" link and remove it from the primary navigation bar.
   $Start = $primaryNavbar->addChild('Our Services');

   // Add the begin here link to the link's drop-down menu.
   $Start->addChild('begin-here', array(
       'label' => 'Website Design',
       'uri' => 'http://www.pumpitsolution.com/website-design',
       'order' => 1,
       'icon' => 'fa-pencil',
   ));


    // Add the overview link to the link's drop-down menu.
   $Start->addChild('overview', array(
       'label' => 'Hosting',
       'uri' => 'http://www.pumpitsolution.com/hosting/',
       'order' => 2,
       'icon' => 'fa-server',
   ));

   // Add the about us link to the link's drop-down menu.
   $Start->addChild('about-us', array(
       'label' => 'Domain Name',
       'uri' => 'http://awesome.pumpitsolution.com/cart.php?a=add&domain=register',
       'order' => 3,
       'icon' => 'fa-globe',
   ));


   // Add the link and its drop-down children to the secondary navigation bar.
   //$secondaryNavbar->addChild($Start);

   // Make sure the contact us link appears as the first item in the
   // secondary navigation bar.
   $Start->moveToBack();


}});

Link to comment
Share on other sites

I would suggest using this hook...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar)
{
   $client = Menu::context('client'); 

   if (is_null($client)) {

       $primaryNavbar->addChild('Our Services')
                       ->setOrder('100');
       $primaryNavbar->getChild('Our Services')
                       ->addChild('begin-here', array(
                           'label' => 'Website Design',
                           'uri' => 'http://www.pumpitsolution.com/website-design',
                           'order' => 1,
                           'icon' => 'fa-pencil',
                       ));
       $primaryNavbar->getChild('Our Services')
                       ->addChild('overview', array(
                           'label' => 'Hosting',
                           'uri' => 'http://www.pumpitsolution.com/hosting/',
                           'order' => 2,
                           'icon' => 'fa-server',
                       ));
       $primaryNavbar->getChild('Our Services')
                       ->addChild('about-us', array(
                           'label' => 'Domain Name',
                           'uri' => 'http://awesome.pumpitsolution.com/cart.php?a=add&domain=register',
                           'order' => 3,
                           'icon' => 'fa-globe',));
   }
});

btw, it's worth mentioning that v7.2 will have a navbar menu item for non logged-in clients that works in a similar way - e.g it shows all product groups, domain registration and domain transfer...

 

awdliCl.png

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