ActiveCampaign
Also available forKeap

[memb_has_membership]

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

Description

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

Shortcode Examples

[memb_has_membership membership="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 membership="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]

Shortcode Parameters

captureCapture the output of the shortcode and route it to a variable for later use. (?)
membershipA comma separated list of membership names to check for.
notYou can use the attribute not=”not”, to reverse the results of the test.
outputContent to be displayed if the test is successful. (Optional, Added in 2.45)
txtfmtA comma separated list of text processing functions to be used to post process the contact fields. (?)

Why Membership Levels and not Tags

Membership levels are composed of sets of tags which can grant or block access. Using a tag check to check for the membership level is less reliable, because a contact may have a membership tag that is blocked by a PAYF, CANC or SUSP tag. This function checks your access against the active membership levels for that contact.

Conditional Memberships

[memb_has_membership] 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 having all access levels active. 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.

Additional Information

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.

For example:

For example:

[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_membership]
[/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]

 

Shortcode Attributes

ConditionalYes
NestableYes
Accepts formattingYes
CapturableYes