How to Show or Hide WordPress Menu Items Using Infusionsoft Tags, Membership Levels or Whether a User Is Logged in Or Not

Memberium Admin — 
In this post we'll show you how to display or hide menu items in WordPress conditionally based on a member's existing Infusionsoft tags.

Controlling menu items conditionally might seem a bit scary at first, but once you understand how it works it's really easy to do.

In certain situations, you'll want to control the visibility of menu items based on a logged in member's existing Infusionsoft tags. Or you'll want to only display specific menu links to logged out visitors.

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 a menu item from a member that doesn't have the Infusionsoft tag to access that membership level.

You can also display widgets conditionally using the same conditional tags covered in this post.

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're using any of the mentioned plugins or themes.

If you use any of these a workaround is you can temporarily deactivate the conflicting plugin/theme to setup 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 who have any of the following Infusionsoft tags: memb_hasAnyTags

To display a menu item to a member who has a specific Infusionsoft tag, you'll need to find the “tag id” of the tag first.

Where can you find the Infusionsoft 'tag ID'?

To find the ID for a tag that's not a membership level (to display a menu item by membership level, you should only use memb_hasMembership or memb_hasAnyMembership and not memb_hasAnyTags), you can find the tag id in Infusionsoft by navigating to CRM > Settings > Tags and the Tag ID's are listed in the ID column as pictured below (be sure to include your own tag ID in place of '130').

membhasanytags-infusionsoft-tagid

To display a menu item to a member who has a specific Infusionsoft tag, for instance, let's say one with a tag id of '130', all you need to do is paste the following function into the “Visibility” field box:

memb_hasAnyTags( "130" )

memb-has-any-tag-menu-function

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( "130" )

If you want to hide or show a menu item from anyone who has ANY of the following Infusionsoft tags you just add a comma between the tag ids.

This will display a menu item to members with any of the following Infusionsoft tags:

memb_hasAnyTags( "130,128" )

This will hide a menu item from anyone with any of the following Infusionsoft tags:

!memb_hasAnyTags( "130,128" )

Any menu items that use the function memb_hasAnyTags will remain hidden until a member is logged in.

How to display a menu item to members who have ALL of the following Infusionsoft tags: memb_hasAllTags

In certain situations, you'll want to display or hide a menu item from members who have multiple Infusionsoft tags.

To display a menu item for a member who has ALL of the following Infusionsoft 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 Infusionsoft tags you would use the following function in the “Visibility” field box:

!memb_hasAllTags( "130,128" )

How to display a menu item to members with a specific membership level: memb_hasMembership

memb_hasMembership() allows you to show or hide a menu item to a member with a specific membership level.

Where can you find the name for a membership level?

In the admin area of your WordPress site, navigate to 'Memberium > Memberships' and look for the name for the membership level you want to show or hide and copy it.

membership level name

Let's say we only want to display a menu item to members who are 'Gold' members.You'd then use the following function in the "Visibility" box (be sure to exactly match the name of your membership level, names are not case sensitive):

memb_hasMembership( "Gold" )

menu-items-by-infusionsoft-tags

If you want to display a menu item to logged in members who are NOT "Gold" Members, you'd use the following example in the "Visibility" field:

!memb_hasMembership( "Gold" )

An example of how you could use this type of logic could be used to display a sales page link to members who are enrolled in our "Free Course".

Once again 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 a menu item from a member who doesn't have the Infusionsoft tag to access that membership level. The menu item will also be hidden from logged out visitors.

Display a menu item based on a user being logged in or not: is_user_logged_in

To only display a menu item to members who are logged in, you'd use the following example in the “Visibility” field box:

is_user_logged_in()

This menu item will be hidden completely from any logged in user and will only display to visitors who are logged out:

!is_user_logged_in()

To see how to use is_user_logged_in() to display a log out or log in link you can check out this post to see how to do this step by step.

Combining Multiple Functions to Create Advanced Conditions

You can combine multiple functions or use any other PHP / WordPress functions together to create more advanced visibility conditions for menu items.

To combine two or more functions together, you just add two ampersands between them like this: &&

In this example we'll say we want to display a menu item link only for "Gold" Members who also have the Infusionsoft tag id of "130":

memb_hasAnyMembership( "Gold" ) && memb_hasAnyTags( "130" )

If we wanted to reverse thew logic of the previous example, you'd use the following logic:

!memb_hasAnyMembership( "Gold" ) && !memb_hasAnyTags( "130" )

Controlling menu items conditionally can be used a lot of different ways to make your Membership site more dynamic for your members based on their past interactions and current membership level. Here are a few examples of how you could use conditional menus with your WordPress site:

  • Showing sales page links to visitors who haven't bought a certain course or product yet.
  • Hiding sales page links/offers from customers who have purchased them already.
  • Dripping content through your main navigation menu.
  • Unlocking new content sequentially upon completion with LearnDash.
  • Showing or hiding certain links, opt in's or targeted offers based on a user's existing Infusionsoft tags.
  • Displaying a log out / log in link if a user is logged in or not.

There are tons of other possibilities of how you could use this feature to create a more personal and unique experience for your members. If you have any questions about how to use conditional statements with Memberium don't hesitate to contact support if you need any help.

Related Posts:

  • Was this Helpful?
  • YesNo