In this post, we’ll show you how to display or hide menu items in WordPress conditionally based on a member’s existing ActiveCampaign tags, or logged in status.
When it comes to menus, they’re very flexible and WordPress allows you to customize every aspect of the menu. With Memberium, you can control the visibility of menu items based on a logged in member’s existing ActiveCampaign tags. One other thing that you can do is to display specific menu items based on whether a user is logged in or logged out.
If a certain page or post is protected by a membership level, and the prohibited action is set to hide or redirect, Memberium will automatically hide that menu item from a member that doesn’t have that ActiveCampaign tag to access that membership level.
So without any further ado, let’s get started!
Install the plugin
The first step is to install and activate the “Menu Items Visibility Control” plugin on your site.
There are a few known issues with some plugins and themes that modify menu behavior (UberMenu 2.x Mega Menus plugin, Add Descendants As Submenu Items plugin, Navception plugin, Suffusion theme, BeTheme, Yith Menu, Kleo Theme, Jupiter Theme).
If you use any of these, menu items visibility will still work properly, but the input dialog will not show up.
If you use any of these a workaround is you can temporarily deactivate the conflicting plugin/theme to set up your menus.
Reactivating the conflicting plugin/theme will cause the “visibility” box to disappear, but the visibility functions will still work correctly.
Once you have the menu items visibility plugin successfully installed, here’s an overview of all the conditional tags you can use to control the visibility of menu items on your site.
How to display a menu item to members with a specific ActiveCampaign tag
To display a menu item to a member who has a specific ActiveCampaign tag, you’ll need to find the “tag id” of the tag first. An easy way to do this would be to go to the “Content Protection” box on any page, type in the tag name and you’d see the tag ID next to it.
In this screenshot, the tag ID is 10.
To display a menu item to a member who has a specific ActiveCampaign tag, for instance, let’s say one with a tag id of ’10’, all you need to do is paste the following function into the “Visibility” field box in the menu:
memb_hasAnyTags( "10" )
To hide the menu item from anyone who has this tag, you just need to add an exclamation mark in front to reverse the logic like so:
!memb_hasAnyTags( "10" )
This will hide the menu item from anyone who has this tag. All other users would be able to view this menu item.
If you want to show a menu item to anyone who has ANY of the following ActiveCampaign tags you just add a comma between the tag ids.
This will display a menu item to members with any of the following ActiveCampaign tags:
memb_hasAnyTags( "130,128" )
This will hide a menu item from anyone with any of the following ActiveCampaign tags:
!memb_hasAnyTags( "130,128" )
Note: Any menu items that use the function memb_hasAnyTags will remain hidden until a member is logged in.
How to display menu item to users who have all ActiveCampaign tags
In certain situations, you’ll want to display or hide a menu item from members who have multiple ActiveCampaign tags.
To display a menu item for a member who has ALL of the following ActiveCampaign tags, you would use the following function in the “Visibility” field box (be sure to add your own tag id’s in place of the example):
memb_hasAllTags( "130,128" )
To hide a menu item from a member who has ALL of the following ActiveCampaign tags you would use the following function:
!memb_hasAllTags( "130,128" )
Display a menu item to a logged in user
To only display a menu item to members who are logged in, you’d use the following function in the “Visibility” field box:
Display a menu item to a logged out user
This menu item will be hidden completely from any logged in user and will only display to visitors who are logged out:
The Menu Items Visibility Control plugin is a very useful plugin as it allows you to show/hide specific menu items based on a particular ActiveCampaign tag or users logged in, or logged out status.
It can have various uses, for example, if you’d like to show an upsell/upgrade page only to your Trial members, and hide the same page from your upgraded members or member with higher membership level. You can show sales page link to users with only a particular tag, or based on whether they’re logged in.
One neat trick would be to show the Login page to only logged out users, and show logout page only to logged in users.
So go ahead, start playing with this useful plugin!