#71 - Hide a menu item when user logs in

#71 - Hide a menu item when user logs in

There are times when you need to hide specific menu items when a user has logged on to your Joomla website. This depends on which version of Joomla you are using, in the older versions of Joomla this could not be done using standard functionality, however from Joomla 1.7 onwards there is a very simple way to do this with ACLs. The article below will show both methonds.  

If you want to hide a whole module eg the menu you can used the trick here: #3 - Hiding a menu once logged in

Joomla 1.7 Onwards

The Joomla Access Control functionality allows you to easily set items which should be displayed to guests, but hidden from logged in users. 

If you go to the User Manager options you will see a setting for the default group that registered users are placed, you will also see a default group for guests (non logged in users). The latter group can be used to create a new group at the same level in the ACL tree for guests.

  1. Create a Guest Group in the User Manager
  2. Add a new Guest Viewing Access Level
  3. Change the default guest group in the User Manager options

Assign modules or menu links to the new group

To hide menu items or module, what you will to do is assign any menu link or module to the newly created Guest level and because it is at the same level in the ACL tree as Registered anything assigned to guest will not be visible to registered users.

Pre Joomla 1.7

So what do we do to hide the menu item for logged in users? A combination of using the Joomla framework (getUser) and a CSS trick (display:none) to hide items. In your template place the following code: 

$user =& JFactory::getUser();
if( !$user->guest ) ?>
<style type="text/css">
.item10 { display:none; }

<?php endif; ?>

replace the 10 in .item10 with the id of the menu item. 

NOTE: this only works on the menu if the menu's module is set to 'List'. If you are familiar with CSS you can use it / extend for the style of any menu item you choose

Want to supercharge your website?

  Our website loads FAST ... just 1.29 seconds. We're hosted on FAST InMotion servers We want YOUR website to be fast too, so we've gotten you an exclusive deal - 47% OFF for DART Creations friends + FREE domain! Check it out NOW!


Popular Content

Joomla extensions to take your website to the NEXT level

Is your Joomla website reaching its full potential? We install many of these extensions on almost ALL of our Joomla sites - why don't you check them out our list of Joomla Extensions and see whether you can take your site to the next level?

Follow us on Social



Where are we hosted?

This site is proudly powered by FAST VPS InMotion Servers and given an insane speed thanks to MaxCDN!

Web Hosting MaxCDN - Speed up your website


InMotion Hosting Review - Recommended Web Hosting servers for business, Joomla, WordPress and ecommerce websites.

inmotion Hosting Review

Advertise on DART-Creations.com

DART Creations is interested in developing partnerships with mutual benefit. If you like the stuff we publish and would like to develop a relationship, we'd be happy to hear from you. Go on - drop us a line - we'd love to hear from you :-)


27 premiums fonts, 91 graphic packs for  $29. Get it NOW - May Only!

summer design bundle

New! DIVI 2.7 WordPress TeMPLATE + PageBuilder

You'll surely create a perfect website with Divi 2.7!

Divi WordPress Theme