Conditionally hide menu items
-
Forgive me if this has been asked before.
There are a number plugins that will provide a way to conditionally hide or show a menu item (see https://ww.wp.xz.cn/plugins/menu-items-visibility-control/ example).
Are there any specifically for PMPro that will hide/show a menu item depending on membership level?
Failing that, what PMPro conditions can be used in the plugin mentioned above?
-
I am interested in this feature as well. I use “membership” and this is a function that is allowed and is outstanding –
Hey guys,
There are a few ways to do this, but unfortunately all will require some custom code depending on what you’re trying to exactly. However, if you just want to hide membership restricted posts entirely from non-members, you can use the “Filter searches and archives?” feature in Memberships > Advanced Settings.
Try that, and if it’s not what you’re looking for exactly, let us know.
Thanks,
JessI am interested in hearing about the custom code. Has anyone done this? The menu’s are the hiccup for me right now… Here is the example (assume 2 levels: Level 1 & Level 2):
No login Menu:
Welcome::Demo::Terms::About::YadaYadaLevel 1 Login:
Welcome::Level 1 Menu Items::Terms::About::YadaYadaLevel 2 Login:
Welcome::Level 1 Menu Items::Level 2 Menu Items::Terms::About::YadaYada
OR
Welcome::Level 2 Menu Items::Terms::About::YadaYadaIs this possible?
I used a different plugin to do this, but the subscription options were not near what I needed, so I have to change. This is all that I think is missing from this plugin to be a totally complete solution for a website… Awesome plugin so far – just the menu’s might be a deal breaker for me…
You can use the plugin that I mentioned above (https://ww.wp.xz.cn/plugins/menu-items-visibility-control/), building conditional tags using PMPro’s
pmpro_hasMembershipLevel()function.Nice… Great find and solution… This is perfect.
So is the usage just as simple as the Level ID joined with OR (if you need multiple levels to have access) or did you find it a bit more challenging than that?
pmpro_hasMembershipLevel() == 1 OR pmpro_hasMembershipLevel() == 2 OR pmpro_hasMembershipLevel() == 3
The function returns true or false, usage examples:
pmpro_hasMembershipLevel(1)
pmpro_hasMembershipLevel(‘Gold’)
pmpro_hasMembershipLevel(array(0,2,’Silver’))See: http://www.paidmembershipspro.com/documentation/require-membership-function/
Thanks for that superpotion!
Has this been resolved?
Resolved 🙂
Now just need to find out how to import existing users and assign levels… 🙁
So, what is the best way to php test for Has NO Level?
Thanks,
MichaelUsers already exist in the site, but not in PMPro… Is more of an exercise in manual editing the user levels on the WP side. 🙁
The plugin lets you update existing users, allowing you to automatically assign membership levels to users, and populate numerous other pmpro fields, simply by adding a few columns to your CSV file.
Does anyone know what is the best way to test for “Has NO Membership Level”?
Thanks,
MichaelMichael, you can use use the pmpro_hasMembershipLevel() function with an ! (NOT operator) in front:
if(!pmpro_hasMembershipLevel()) { //do something }
The topic ‘Conditionally hide menu items’ is closed to new replies.