Skip to:

Certain menu items to appear only when logged in

  • Greetings,

    This is a great plugin, and is working well with my site.

    One thing I would like to be able to do is add certain items to the navbar, but have them only be visible to users if they are logged in. Is there any way to do this?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Profile photo of pcwriter



    The way the plugin is coded now, you would need to edit bp-wp-navbar.php and wrap one of the 5 available menus in a is_user_logged_in conditional (I know, 5 menus was overkill, but that was my 1st plugin and venture into custom menus :-( ).

    But you have a pretty good idea there! The next version, which will be released shortly after BP1.3, will have much more streamlined code. And I’ll try to incorporate this idea into it then.

    The new ul structure of wp_nav_menus puts all top-level items of custom menus in the main nav, with sub-level items in dropdowns. So, one menu for ‘Everyone’ and one for ‘Logged-in Only’ would work well in this case.

    Yea, would be cool if there were just an option next to the menu created for “logged in” and “everyone”.

    Could you elaborate a little more on “wrapping” the menus, please?

    Thanks for the quick reply.

    Profile photo of pcwriter



    Open bp-wp-navbar.php and scroll down to about line 178 where you see the following code group (you can use whichever one of the bp_adminbar_pages menus you like – 1,2,3,4 or 5):

    <li><a href=&quot;"></a>
     'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages2')) ?>

    Add this tag to the empty line just above that snippet:

    And then close the tag by adding this to the empty line just below the snippet:

    I just tried it on a test site and it works like a charm. When logged in, the menu appears, then disappears when you log out.

    Profile photo of terryplatt


    I guess maybe I do not have the talent necessary to organize my material but I always need more menus. So, five seems pretty restrictive to me, not overkill. Do I need better organization skills?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Certain menu items to appear only when logged in’ is closed to new replies.
Skip to toolbar