Display different menus for logged-in users

ThirstyAffiliates Review

Adding this snippet in the location you wish to display your navigation, would show one menu to logged-in users and another when they are not logged-in.

if ( is_user_logged_in() ) {
     wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) );
} else {
     wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) );

Comments  Leave a Reply

  1. How do you add this to a theme? The above code shows nothing in the navigation menu

  2. Wordpress Buddypress Different Menu for Logged In and Non-Logged in Users | Archturus Media September 11, 2012 at 5:54 pm

    […] I’ve been in the process of building an online community for the Utah Grotto of the National Speleological Society and ran into a wall when it comes to creating a different menu for logged in and non logged in users. The primary problem was in the fact that several of the buddypress supported themes only support one menu and you need at least two in order for the is_user_logged_in() function to work properly. So here was the solution I came up with after referencing the following sites: http://wpsnipp.com/index.php/theme/display-different-menus-for-logged-in-users/ and http://smartcoderszone.com/2010/07/how-to-add-multiple-menu-in-wordpress/. […]

  3. AWESOME! Thank you a billion times!

    1. Np Erwin, glad that I could help.

  4. Thank you – I’ll give this a try 🙂 

    Just found this site and I think it is going to be invaluable to me.

    Thank you.

    1. Hi Janice glad to hear you like wpsnipp, hope that you enjoy all the snippets.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!