Description
This is a conditional shortcode that checks whether a $_POST variable (form submission field) exists or matches a specific value, then displays content accordingly. It uses an [else_memb_if_post] block for the fallback when the condition is not met.
Shortcode Examples
Check if a POST field named first_name was submitted with the value David:
[memb_if_post key="first_name" test="=" value="David"]
Welcome back, David!
[else_memb_if_post]
Please enter your name.
[/memb_if_post]
Check if a POST field exists at all:
[memb_if_post key="email"]
Your email has been received.
[else_memb_if_post]
Email is required.
[/memb_if_post]
Check if a submitted value is within a numeric range:
[memb_if_post key="age" test="range" value="18,99"]
You are eligible.
[else_memb_if_post]
You must be 18 or older.
[/memb_if_post]
Shortcode Parameters
key | (Required) The $_POST variable name (form field 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 form field name from a submitted POST request (e.g., an HTML <input name="first_name"> field). If value is omitted and test is empty, the shortcode checks for the key’s existence only. This shortcode is most useful on thank-you pages or form confirmation pages.
Shortcode Attributes
| Conditional | Yes |
|---|---|
| Nestable | Yes |
| Accepts formatting | Yes |
| Capturable | Yes |