Discover in this tutorial how to display a different menu depending on the user’s membership level in Restrict Content Pro, using code.
If you use the Restrict Content Pro plugin and you have different membership levels where you offer different content you may want to show a different menu depending on the membership level of the subscriber.
This can be very practical if you want to show in the menu exclusive content for each membership level.
Let’s see how to achieve this:
Snippet to display a different menu depending on the Restrict Content Pro membership level
First of all, you must create two menus, one that is the one you want to show to non-logged users and the other to subscribers depending on their level.
Once you have this menu for identified users, add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1065 code snippets of this website, login or subscribe here.
In this snippet you use the wp_nav_menu_args
filter in combination with the is_user_logged_in
conditional tag and a couple of Restrict Content Pro functions to display one menu or another depending on whether the user is logged in or not and their membership level.
In this case, 3 menus are used:
- “User not logged in” -> Will be displayed to users not logged in
- “Subscribers level 1” -> Will be displayed to level 1 subscribers in Restrict Content Pro
- “Subscribers level 2” -> Will be shown to level 2 subscribers in Restrict Content Pro
But if you want you can use another nomenclature. If you do so, you only have to replace it in the snippet.
The membership ID can be seen in Restrict > Membership Levels by hovering over the level:
This code works for both Genesis child themes and other WordPress themes.
Conclusions
You can see how easy it is to load a specific menu depending on the membership level the user is subscribed to in Restrict Content Pro.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉