WordPress Plugin for Dynamic Menus Based On Logged In Status

Cristian Antohe
Last Updated: 13/05/14

Dynamic Menu for Logged In Users
Displaying dynamic menus based on logged in status is quite straight forward and any developer you’re gona ask will tell you the same thing.

Regardless of that, up to this point, the only way show a different menu to your logged in users was to add a bit of code to your theme header, some conditional tags and you’re good to go.

Register your logged in and visitors menus – add the following code to your functions.php file:

Include the wp_nav_menu calls in your theme’s header.php file:

It’s all fairly straight forward, but the problem appears when you try to explain that to a non technical person. Simply put, it’s just no good enough.

So instead of copying and pasting code without even understanding what it dose, wouldn’t it be simpler to just:

  • activate a plugin
  • automatically get access to logged in “Theme Locations” in your Menus WordPress interface
  • create another menu for logged in users
  • assign it to the correct location and you’re done

No coding, no messing around with conditional tags, and most importantly, I can now answer another questions with “Just install this plugin and you’re good !”.

Dynamic Menu for Logged In Users Plugin.

It’s only 37 line long, doesn’t have any options, and generates Logged In Theme Locations for every predefined theme location inside your theme and serves the logged in version to… well… logged in users.

You can download the file but here’s the code for it as well:

UPDATE

I got a really cool suggestion by Pippin Williamson regarding a similar plugin but with more fine grained functionality: Nav Menu Roles. You can hide custom menu items (not just entire menu locations) based on user roles. Great to build a dynamic menu for a membership site!

If you liked this plugin you’re gona love Profile Builder PRO

Because default WordPress user registration and login is NO GOOD for modern websites.
Find out more about Profile Builder Pro (Lots of Pictures Included).

13 thoughts on “WordPress Plugin for Dynamic Menus Based On Logged In Status

    Nav Menu Roles is great, but it can’t hide the page entirely if it’s directly typed in the browser (in case the member who doesn’t have the permission to view that page knows the exact permalink of the page in your site that he or she wants to view).

    Do you know any plugin that can do such custom restrictions for each page? Or can you suggest a workaround? 🙂

    Reply

    Hmm, I am really getting confuse with php code :D, but I will always try, this one of tutorial will help me to understand

    thanks

    Reply

    Thanks Christian, works perfectly and saved me headaches.

    Reply

    Thank you, thank you, thank you Christian! This saved me a lot of pain. Nav Menu Roles is great but it interferes with other plugins. Yours is plain, simple and does what is needed.

    Kudos!

    Reply

    Hello, Mr. This has been posted a couple of time ago, but I’m facing a kind of problem to configure the code in my site, I’d like to know how to configure the “two” menus in my site? What name should I call them?

    Reply

    Thanks very much for your code Cristian.

    This is perfect and exactly what I was looking for.

    Reply

    Thank you for this excellent piece of code! Helped me a lot since in my current setup Nav Menu Roles is too complicated. Thanks for posting this!

    Reply

    Hi Christian thanks a gazillion!! it took me 2days searching the web trying to figure out a way to display diferent items on my two menus(main nav & top menu) to logged-in & logged-out with no luck, even tried Nav Menu Roles plugin, just got some class conflict errors. Long story short, I tried your plugin & worked like charm….. its really awesome!! You saved tons of hours!! Once again thank you.

    Reply

    This was a great stuff. It helped me alot in setting similar sort of menus for different users at specific time. Can this guide work for different user role as well?

    Reply

    How can i assign menu for particular user role.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.