The [frm-condition] shortcode is used to compare two values before displaying something on the page. Compare a field value another field value, a value in the url, a stat returned by the frm-stats shortcode, and many more.
Use it in a view, directly on a page, in an email, as a default value, or anywhere else that shortcodes are processed.
- source - Where to get the first value for comparison. Use the name of any other shortcode (including a custom shortcode) or 'param'.
- equals, not_equal, greater_than, less_than, like - Include the second value to compare. ie equals=10 or greater_than=100.
- param - If source=param is used, set the name of the param in the URL.
- Any parameter to pass to the shortcode specified in the 'source' parameter.
- content - Content that would typically be inside the source shortcode. For example, the content of the [frm-math] shortcode is a math expression: [frm-math]  *  [/frm-math].
To use this with [frm-condition], you'd put the math expression in the content param, like so:
[frm-condition source=frm-math content=" * " greater_than="10"]show if result is greater than 10[/frm-condition]
Note: Standard WordPress shortcodes, like frm-stats, can't be used in the content param.
Compare two fields in a View
Show a value when field 391 and 390 are the same. Change these field ids to match your own. [id] is left as is as long as you are comparing to a value in the same entry.
[frm-condition source=frm-field-value field_id=391 entry=[id] equals=""]your content here[/frm-condition]
Compare a statistic
This example will show the statistic from the frm-stats shortcode only when it is higher than 10. Replace 'text-field' with the id or key for the first field to compare.
[frm-condition source=frm-stats id=text-field type=count greater_than=10][frm-stats id=text-field type=count][/frm-condition]
Show a message on a page
Display the message "You've exceeded your monthly limit" if the user's value in field 72 is less than the value of total_cost param in the URL or set in another shortcode.
[frm-condition source=frm-field-value field_id=72 user_id=current less_than=param param=total_cost]You've exceeded your monthly limit.[/frm-condition]
Check the value of a param
Test if a param is set or has any value. Replace 'color' with the name of the param you want to test.
[frm-condition source=param param=color]content to show if the color param is set[/frm-condition]
Test if a param has a particular value.
[frm-condition source=param param=color equals="yellow"]content to show if the color param is set to "yellow"[/frm-condition]
Compare to a custom shortcode
- Show content based on current user's role
- Show content if current user is logged in
- Show content based on the current month.
Show users which forms they have filled out
In a situation where a user has many forms to fill out, you may want to show him/her which ones s/he's already filled out and which ones s/he still needs to fill out.
For each form:
- Create a stat to determine the number of entries the user has filled out for that form. It would look something like this, where 100 is the id of a field in the form that always has a value:
[frm-stats id=100 type=count user_id=current]
Tip: check to make sure your stat is showing the correct values before moving to the next step.
- Use the stat in [frm-condition] to determine if the user has filled out the form and to display an appropriate message, like so:
[frm-condition source=frm-stats id=100 type=count user_id=current greater_than=0]Registration form: completed[/frm-condition]
[frm-condition source=frm-stats id=100 type=count user_id=current equals=0]Registration form: needs to be filled out[/frm-condition]
Hide checkbox/radio options after n submissions
- In your Settings → Customize HTML, separate out each of your checkbox or radio options. Replace [input] with [input opt=1] until you have done this for each option in the field.
- Create a stat to determine how many times an option has been used. (Optional) Test to make sure it works properly before proceeding. Your stat would look something like:
[frm-stats id=25 type=count 25="red"]
Replace 25 with the ID of the checkbox or radio field and the value of a particular option is "red"
- Surround each option with [frm-condition] so that it will only be shown if it's been used less than its maximum number of times. Use frm-stats as the source. Change the "red" in 25="red" to match the value of the current option. Set the appropriate less_than (or less_than_or_equal_to) value in frm-condition. For example, if "red" can only be chosen 10 times, your final shortcode may look something like:
[frm-condition source=frm-stats id=25 type=count 25="red" less_than=11][input opt=1][/frm-condition]