Table of Contents
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.
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).
Related Articles
Beginner’s Guide to: What Is WordPress?
Ever now and again the question arises with new clients that aren't really tech savvy: "What Is WordPress?" What I'm hoping to achieve with this post is to drop the technical jargon for a minute and explain in down to earth words what is WordPress, how can it help you, what is WordPress.com, what's a […]
Continue ReadingBest WordPress Monetization Plugins & Tactics to Grow Your Revenue
You will agree that finding the best WordPress monetization plugins (and tactics) to grow your revenue is challenging. If that describes your situation, you're in the right place, and we have your back as always. Like you, I had big dreams when I started my first WordPress site. Also, like you, I was skeptical about […]
Continue ReadingA Guide to WordPress Forum Plugins: The Best Plugins & How To Manage Them
If your WordPress site is designed to serve and engage with a community, you’ll need to install a WordPress forum plugin. Forum plugins add a platform where users can ask questions, provide answers, and join in discussions. It promotes engagement and gives users a sense of being part of a community. You can use it […]
Continue Reading
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? 🙂
That shouldn’t be a problem. That’s what Membership plugins are for… You can try out the Members plugin by Justin Tadlock. We’re using it on Cozmoslabs and not only dose it work it’s also free.
http://wordpress.org/extend/plugins/members/
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
Thanks Christian, works perfectly and saved me headaches.
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!
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?
Thanks very much for your code Cristian.
This is perfect and exactly what I was looking for.
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!
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.
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?
Yes, that would do just as well.
How can i assign menu for particular user role.
Hi! How does this feature works today?