WordPress Plugin for Dynamic Menus Based On Logged In Status

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).

About Cristian Antohe

Cristian Antohe is the co-founder Cozmoslabs. He's a WordPress developer, web designer and Open Source fanatic. He's part of the team that developed Profile Builder and WordPress Creation Kit and also helps curate wpMail.me.

Find me on: Google + | Twitter

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

  1. 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? :)

  2. 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!

  3. 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?

Leave a Reply

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


× 8 = thirty two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>