Description
This is a conditional shortcode that checks whether a $_GET variable (URL query string parameter) exists or matches a specific value, then displays content accordingly. It uses an [else_memb_if_get] block for the fallback when the condition is not met.
Shortcode Examples
Check if a URL parameter named source equals google (URL: ?source=google):
[memb_if_get key="source" test="=" value="google"]
Welcome from Google!
[else_memb_if_get]
Welcome!
[/memb_if_get]
Check if a URL parameter exists at all (no value means existence check):
[memb_if_get key="coupon"]
Your discount has been applied.
[else_memb_if_get]
No coupon code found.
[/memb_if_get]
Case-sensitive comparison:
[memb_if_get key="source" test="=" value="Google" caseinsensitive="false"]
Exact match!
[/memb_if_get]
Shortcode Parameters
key | (Required) The $_GET variable name to check. |
|---|---|
test | (Optional) Comparison operator. Default: =. Valid operators: =, ==, ===, eq, ne, !=, !==, gt, >, lt, <, ge, >=, le, <=, bw (begins with), ew (ends with), contains, in, !in, range, !range. |
value | (Optional) The value to compare against. If omitted and test is empty, checks for the key’s existence only. |
caseinsensitive | (Optional) Whether to perform a case-insensitive comparison. Default: true. |
capture | Captures the shortcode output and routes it to a variable for later use. |
txtfmt | (Optional) Comma-delimited list of text processing functions to apply to the output. |
Additional Information
The key parameter refers to the URL query string key (the part after ? and =). For example, in https://example.com/page?source=google, the key is source and the value is google. If value is omitted and test is empty, the shortcode checks for the key’s existence only.
Shortcode Attributes
| Conditional | Yes |
|---|---|
| Nestable | Yes |
| Accepts formatting | Yes |
| Capturable | Yes |