[memb_has_any_tag]
This Applies to
OTHER DOCS Available
Shortcode Video
Summary
Conditional shortcode to control access to portions of a post, page or widget based on the logged in user’s tags.
Shortcode Examples
To display a message if someone has a tag
[memb_has_any_tag tagid=123]Message[/memb_has_any_tag]
To display a message if someone has a tag
[memb_has_any_tag tagid=123 output=message]
Check a radio button in a form if the user has a tag:
<input type="radio" name="foo" value="123" [memb_has_any_tag tag_id=101 output="checked"] >
Check a checkbox in a form if the user has a tag:
<input type="checkbox" name="foo" value="123" [memb_has_any_tag tag_id="103" output="checked"] >
Select a dropdown option if the user has a tag:
[memb_has_any_tag tagid=103 output=selected] >Foo
Display “Yes” or “No” if the user has the tag:
[memb_has_any_tag tagid=105]
Display output only if the user has the tag:
[memb_has_any_tag tagid=107 output="You have the tag!"]
[memb_has_any_tag tagid=107] You have the tag! [/memb_has_any_tag]
Display output only if the user does not have the tag:
[memb_has_any_tag tagid=109 not=not output="You do not have the tag!"]
[memb_has_any_tag tagid=101,102] Shown to users with these tags [else_memb_has_any_tag] Shown if user doesn’t have specified tags [/memb_has_any_tag]
When written out to completion the shortcode looks like this,
[memb_has_any_tag tagid=1290] This is only visible to those who have tag ID 1290. This tag is named "Demo Master" [else_memb_has_any_tag] Shown to anyone else, who is lacking those tags. [/memb_has_any_tag]
is the same as
[memb_has_any_tag tagid="Demo Master"] This is only visible to those who have the tag named "Demo Master". [else_memb_has_any_tag] Shown to anyone else, who is lacking those tags. [/memb_has_any_tag]
If you’d like to restrict access to allow more than one group to see content, while restricting others who don’t have those tags, you can do so by separating each tag name or ID with a comma.
[memb_has_any_tag tagid=TagA,TagB,123,456] Shown to users with these tags [else_memb_has_any_tag] Shown if user doesn’t have specified tags [/memb_has_any_tag]
Or:
[memb_has_any_tag tagid=101,102] Shown to users with these tags [else_memb_has_any_tag] Shown if user doesn’t have specified tags [/memb_has_any_tag]
To display the list of purchased items from Infusionsoft, you can use the shortcode in the following format:
[memb_has_any_tag tagid=ProductTag1]Product Name1[/memb_has_any_tag] [memb_has_any_tag tagid=ProductTag2]Product Name2[/memb_has_any_tag] [memb_has_any_tag tagid=ProductTag3]Product Name3[/memb_has_any_tag]
Show/hide content based on a tag category. For instance, if a user has any tag inside of a certain Infusionsoft tag category, they will be able to see the content:
[memb_has_any_tag category_id=123] Message [/memb_has_any_tag]
Shortcode Parameters
capture: Capture the output of the shortcode and route it to a variable for later use. (Read More…)
category_id: This parameter takes a single category id number. Category name or list of categories won’t work. For instance, if a user has any tag inside of a certain Infusionsoft tag category, they will be able to see the content. (Optional, Added in 2.70)
contact_id: The contact ID of a different contact. Optional.
except_contactid, except_contactids: A comma separated list of Infusionsoft Contact ID’s that the current user must not be one of in order for the test to succeed.
except_tagid:, except_tag_ids: A comma separated list of tag names or tag ID’s that the current user must not have.
min: When matching against multiple tags, the minimum number of tags to match. Defaults to 1. (Optional).
not: You can use the attribute not=”not”, to reverse the results of the test.
output: Message to be displayed if the test is successful. (Optional, Added in 2.45)
tagids, tag_ids, tagid, tagids: A comma separated list of tag names or IDs.
txtfmt: A comma separated list of text processing functions to be used to post process the contact fields. (Read More…)
Shortcode Attributes
Conditional: Yes (Read More…)
Nestable: Yes (Read More…)
Accepts formatting: Yes (Read More…)
Capturable: Yes (Read More…)
Additional Information
The [else_memb_has_any_tag] shortcode is entirely optional. If you skip the [else_memb_has_tag] 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_any_tag1] [memb_has_any_tag2] [else_memb_has_any_tag2] [/memb_has_any_tag2] [else_memb_has_any_tag1] [/memb_has_any_tag1]
If the shortcodes end before the next one starts, you are not nesting them and do not need to number them:
[memb_has_any_tag] [else_memb_has_any_tag] [/memb_has_any_tag] [memb_has_any_tag] [else_memb_has_any_tag] [/memb_has_any_tag]
If you are nesting different shortcodes, you do not need to number them:
[memb_has_all_tags] [memb_has_any_tag] [else_memb_has_any_tag] [/memb_has_any_tag] [else_memb_has_all_tags] [/memb_has_all_tags]