How to hide a menu once a user logged in - Joomla

Discussion in 'XHTML/HTML/CSS' started by balajia, Jul 15, 2010.

  1. balajia New Member

    Member Since:
    Jul 1, 2010
    Message Count:
    27
    Likes Received:
    1
    Occupation:
    Web Developer
    Location:
    India
    $user =& JFactory::getUser();

    $user_id = $user->get('id');

    This returns the user id of the user. Therefore the code to do this is check whether the current user has a valid id (i.e. they are logged), if not load the module:

    <?php
    $user =& JFactory::getUser();
    $user_id = $user->get('id');
    if (!$user_id)
    {
    ?>
    <jdoc:include type="modules" name="left" />
    <?php
    }
    ?>
  2. Adam H Administrator

    Member Since:
    Jan 7, 2008
    Message Count:
    2,892
    Likes Received:
    188
    Occupation:
    Head of Search
    Location:
    Norfolk Uk
    Please state in the title and the post what this applies to , Not everyone will know this is a Joomla related code
  3. balajia New Member

    Member Since:
    Jul 1, 2010
    Message Count:
    27
    Likes Received:
    1
    Occupation:
    Web Developer
    Location:
    India
  4. Adam H Administrator

    Member Since:
    Jan 7, 2008
    Message Count:
    2,892
    Likes Received:
    188
    Occupation:
    Head of Search
    Location:
    Norfolk Uk
    No you didnt :p , i changed it for you :)
  5. balajia New Member

    Member Since:
    Jul 1, 2010
    Message Count:
    27
    Likes Received:
    1
    Occupation:
    Web Developer
    Location:
    India

Share This Page