[memb_has_all_tags]

OTHER DOCS Available

Summary

Conditional shortcode to control access to portions of a post, page or widget based on the logged in user’s tags.

Shortcode Examples

Check a radio button in a form if the user has multiple tags:

<input type="radio" name="foo" value="123" [memb_has_all_tags tag_id="101,103" output="checked"] >

Check a checkbox in a form if the user has multiple tags:

<input type="checkbox" name="foo" value="123" [memb_has_all_tags tag_id="101,103" output="checked"] >

Select a dropdown option if the user has multiple tags:

<option value="foo" [memb_has_all_tags tag_id="103,105" output="selected"] >Foo</option>

Display “Yes” or “No” if the user has multiple tags:

[memb_has_all_tags tag_id="105,107"]

Display output only if the user has multiple tags:

[memb_has_all_tags tag_id="107,109" output="You have both tags!"]
[memb_has_all_tags tag_id="107,109"] You have both tags! [/memb_has_all_tags]

Display output only if the user does not have the tag:

[memb_has_all_tags tag_id="109,11" not="not" output="You do not have both tags!"]

Shown to users with these tags [else_memb_has_all_tags] Shown if user doesn’t have specified tags [/memb_has_all_tags]

[memb_has_all_tags tag_id="101,102"]
   Shown to users with both of these tags
[else_memb_has_all_tags]
   Shown if user doesn’t have both specified tags
[/memb_has_all_tags]

 

Shortcode Parameters​

capture:  Capture the output of the shortcode and route it to a variable for later use. (?)

except_contact_id:  A comma separated list of ActiveCampaign Contact ID’s that the current user must not be one of in order for the test to succeed.

not:  You can use the attribute not=”not”, to reverse the results of the test.

output:  Content to be displayed if the test is successful.  (Optional, Added in 2.45) 

tag_id: A comma separated list of tag names or IDs.  All tags listed must be held to succeed.

txtfmt: A comma separated list of text processing functions to be used to post process the contact fields. (?)

One of the core functions of Memberium is to control access to the pages on your WordPress website based on the identity of the logged in member. This is useful when you want to prevent access to content, or to dynamically control what content is displayed to visitors based on the tags they have.

Sometimes you may want (or need) a finer detailed way to control access to parts of your page, or to display different content in areas of your pages to your members based on their tags.  The most common way to check for tags is to use the [memb_has_all_tags] shortcode which does a loose check to see if the current user has any of the listed tags.  Sometimes you need a more strict test and to determine if the user has ALL of a set of tags.  For this case you would use [memb_has_all_tags].

Why Tags?

ActiveCmpaign uses tags to segment your audience to make your marketing more effective. Similarly, you can use those same tags to control how Memberium behaves when your members login to the site.

Tag Names vs. Tag ID’s

Like it’s cousing [memb_has_all_tags], this shortcode can use either the Tag ID, or the Tag Name.  You can find the tag names and IDs in ActiveCampaign, by going to CRM settings.  Multiple Tag Names and ID’s can be used in a single shortcode by separating them with a comma.  Do not include extra spaces after or before the comma.

Tag Names

The advantage of using Tag Names is that it makes the code VERY easy to read, which is useful when setting up and troubleshooting your shortcodes.  No more guessing what Tag #781 is.  Tag Names do require the tag to be unique int the system.  Additionally the are more resilient to deletion since if you delete the tag, and recreate it and the shortcode will automatically work with the new tag.

Tag ID’s

The advantage of using Tag ID’s is that they’re unchanging and faster to process and more specific if you have multiple tags with the same name in different categories.  Generally we recommend to NOT re-use the same tag name, but if you do you can specify the tag more accurately by using the Tag ID#.

A Note on Testing for Membership Levels

It is not recommended to use [memb_has_all_tags] to test for access to Membership Levels.  Membership levels consist of a group of tags and a user’s membership level is determined by the mix of tags they have, not just the presence of the membership tag itself.  If you need to test for membership levels, you should use the [memb_has_membership] shortcode instead, which is designed with the membership level concept in mind.  Additionally there is the [memb_has_payf] shortcode for testing for the various PAYF tags.

Testing for ANY Tags

If you need to test to see if a user has ANY of the tags in a set, you should use [memb_has_any_tags] instead.

Usage Inside HTML Tags

As of WordPress 4.3, you cannot use open and closing shortcodes inside of HTML tags.  We provide a parameter called “output”, to enable you to conditionally display output if the tag test succeeds.  This is especially useful in HTML forms where you may want to add the attribute “selected” or “checked” to pre-select a form option.

Conditional Tags

[memb_has_all_tags] is a conditional shortcode. Conditional shortcodes perform a test and then display (or don’t display) the content within the shortcode depending on the result of the test. Conditional shortcodes are often nestable so that you can perform multiple tests. All tests are binary meaning they resolve to a simple true-false / sucess-fail / yes-no condition.

Nesting

If you have a series of tests, one after another, you may need to nest your shortcodes.

Administrators

Administrator accounts are always treated as successfully passing all tests. It is not possible to get a failure result as an Administrator. It is recommended that you create regular subscriber users to test the behavior of the site.

Shortcode Attributes

Conditional: Yes (?)
Nestable: Yes (?)
Accepts formatting: Yes (?)
Capturable: Yes (?)

Additional Information

The [else_memb_has_all_tags] shortcode is entirely optional.  If you skip the [else_memb_has_all_tags] clause, then the contents of the shortcode will only be displayed on success, and nothing will be displayed on failure.

For more complex conditions, you can nest conditional shortcodes within each other.

In order to keep things clear, as you nest your shortcodes, put a digit at the end of the shortcode name, so that the shortcode processor can tell which shortcode pieces go together.

For example:

[memb_has_all_tags1]
     [memb_has_all_tags2]
    [else_memb_has_all_tags2]
    [/memb_has_all_tags2]
[else_memb_has_all_tags1]
[/memb_has_all_tags1]

If the shortcodes end before the next one starts, you are not nesting them and do not need to number them:

[memb_has_all_tags]
[else_memb_has_all_tags]
[/memb_has_all_tags]
[memb_has_all_tags]
[else_memb_has_all_tags]
[/memb_has_all_tags] 

If you are nesting different shortcodes, you do not need to number them:

[memb_has_all_tags]
     [memb_has_all_tags]
    [else_memb_has_all_tags]
    [/memb_has_all_tags]
[else_memb_has_all_tags]
[/memb_has_all_tags]

 

FAQ

 

 

9 ways to add more value to your membership site

[memb_has_all_tags]

This Applies To