Conditional shortcode to control access to portions of a post, page or widget based on the logged in user’s membership level.
[memb_has_membership memberships=gold] Shown to users with the gold membership level [else_memb_has_membership] Shown if user doesn’t have the gold membership level [/memb_has_membership]
If you’d like to restrict access to allow more than one group to see content, while restricting others who don’t have those memberships, you can do so by separating each membership name with a comma.
[memb_has_membership memberships=gold,silver] Shown to users with either gold or silver or both [else_memb_has_membership] Shown if user doesn’t have specified tags [/memb_has_membership]
If you have spaces in your Membership names then add quotes around the comma seperated list. For instance, [memb_has_membership memberships=”Gold Level”] or [memb_has_membership memberships=”Gold,Silver,All Access”]
capture: Capture the output of the shortcode and route it to a variable for later use. (?)
memberships: A comma separated list of membership names to check for.
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)
txtfmt: A comma separated list of text processing functions to be used to post process the contact fields. (?)
The [else_memb_has_membership] shortcode is entirely optional. If you skip the [else 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.
[memb_has_membership1] [memb_has_membership2] [else_memb_has_membership2] [/memb_has_membership2] [else_memb_has_membership1] [/memb_has_membership1]
If the shortcodes end before the next one starts, you are not nesting them and do not need to number them:
[memb_has_membership] [else_memb_has_membership1] [/memb_has_membership] [memb_has_membership] [else_memb_has_membership] [/memb_has_membership]
If you are nesting different shortcodes, you do not need to number them:
[memb_has_membership] [memb_has_any_tag] [else_memb_has_any_tag] [/memb_has_any_tag] [else_memb_has_membership] [/memb_has_membership]
ActiveCampaign Shortcode Documentation
Looking for info on the ActiveCampaign version of this shortcode?