[memb_switch]

Version Added 2.43

Summary

This shortcode allows you to display or hide content to users based on tags

Shortcode Examples

[memb_switch]
     Foo
[case any_tag=bar]
     Has Bar Tag [memb_contact fields="FirstName"]
[case all_tags=122,102,123]
     Has 122,102 and 103 [memb_contact fields="FirstName"]
[else]
     Has Nothing. Is sad.
[/memb_switch]

In this example, “Foo” would not be displayed because there is no [case] test in front of it.

“Has Bar Tag” would be displayed only if the currently logged in user had the tag named “bar”.

“Has 122,102 and 103” would be displayed only if the user had all 3 tags 122, 102, and 123.

“Has Nothing. Is sad.” would only be displayed if all the previous tests were false.

Shortcode Parameters

any_tag: Checks if the user has any of the tags specified before displaying content.  This attribute is required to evaluate the condition.

all_tags: Checks if the user has all the tags specified before displaying content.  This attribute is required to evaluate the condition.

Description

Like [memb_has_any_tag] and [memb_has_all_tags], this shortcode allows you to display or hide content based on the tags that the logged in person has. It allows you to use a single conditional shortcode to test multiple conditions.

This shortcode is based on the “switch” conditional structure found in PHP and other C-based languages. The switch statement is similar to a series of [memb_has_any_tag] or [memb_has_all_tags]. Rather than create many nested structures, you can use a single switch to test for each of these conditions rapidly in order.

The [memb_switch] shortcode executes each test from start to finish. It displays the content following a successful test. If there is content in the [memb_switch] but before one of the tests, then that content will not be displayed.. Only when a [memb_case] shortcode is found with successful test does Memberium process the following content. You can match multiple statements. ONLY

If none of the statements match, then the content following the [else] test will be displayed. This is analogous to a PHP/C “default” condition.

If you are using [memb_switch] and discover that you need an additional check, please contact us at support@memberium.com to discuss how we can help.

Shortcode Attributes

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