Hiding Menu Items from Logged in Members

Last post 02-08-2010, 4:16 PM by Poetic Apricot. 2 replies.
Sort Posts:
  •  02-04-2010, 3:11 PM 16644

    Hiding Menu Items from Logged in Members

    Using the following Javascript (placed in Settings > Global JavaScript) you can hide selected menu items from logged in users:

     

    <script type="text/javascript">

    if (document.getElementById('idLoggedName')) {

      var publicLinks = new Array();
      publicLinks[0] = "idMainMenuItem435606";
      publicLinks[1] = "idMainMenuItem435618";
      publicLinks[2] = "idMainMenuItem435619";
      publicLinks[3] = "idMainMenuItem435356";

      var TotalLinks = publicLinks.length-1;

      for (LinkCount=0;LinkCount<=TotalLinks;LinkCount++) {
        var menuItem = document.getElementById(publicLinks[LinkCount]);
        if (menuItem){
          menuItem.style.display = 'none';
        }
      }

    }
    </script>

    To use it, simply change publicLinks[0] = "<menu-item-id-name>"; to include the ID of the menu item (you can find the id by viewing the page source of using the FireBug addon for Firefox). Add a new line for each additional menu item and increase teh number inside of the square brackets.


    Poetic Apricot (Matthieu)
    http://twitter.com/PoeticApricot
    Need help? Give me a call! 1-877-493-6090

    Customization help isn't a service we provide; I will do my best to help you in the forums as time permits however I recommend consulting our partners
  •  02-06-2010, 11:18 PM 16780 in reply to 16644

    Re: Hiding Menu Items from Logged in Members

    I took a look at this code and I can't seem to locate the menu ID.  On my website  (www.radtechintl.org), the firebug discloses the menu item as follows:  <a href http://www.radtechintl.org/default aspx?pageid=186031>Join Now </a>. 

     I tried to enter the code as publicLinks[0] = "Subscriptions", which didn't do anything. 

    Am I missing something or is there something different about my website that doesn't allow this code to work?

  •  02-08-2010, 4:16 PM 16808 in reply to 16780

    Re: Hiding Menu Items from Logged in Members

    The ID can be found a few lines above the link. For your Join now page the line looks like this:

    <td id="idMainMenuItem186050" class="item itemNormalLeaf">
    The idMainMenuItem186050 is the ID you are looking for.

    Poetic Apricot (Matthieu)
    http://twitter.com/PoeticApricot
    Need help? Give me a call! 1-877-493-6090

    Customization help isn't a service we provide; I will do my best to help you in the forums as time permits however I recommend consulting our partners
View as RSS news feed in XML
Membership Software - Wild Apricot