Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

Entries & ReportsListing Entries
Compare Two Values for Display

Compare Two Values for Display

— Premium Feature —

Use the frm-condition shortcode to compare two values before showing something on the page. Compare a field value to another field value, a value in the URL, a stat returned by the frm-stats shortcode, and more.

Use it in a View, directly on a page, in an email, as a default value, or anywhere else that shortcodes are processed.

Parameters

  • source: Where to get the first value for the comparison. Use the name of any other shortcode (including a custom shortcode) or param.
  • equals, not_equal, greater_than, less_than, greater_than_or_equal_to, less_than_or_equal_to, like, not_like, starts_with, ends_with: The second value to compare. For example, equals=10 or greater_than=100.
  • param: The name of the param in the URL. Use it with source=param, or set a comparison to param (for example, less_than=param) to compare to the param's value.
  • Any parameter to pass to the shortcode named in the source parameter.
  • content: Content that usually goes inside the source shortcode. For example, the content of the frm-math shortcode is a math expression: [frm-math] [100] * [102] [/frm-math].
    To use this with frm-condition, put the math expression in the content parameter:
    [frm-condition source=frm-math content="[100] * [102]" greater_than="10"]show if result is greater than 10[/frm-condition]
    Standard WordPress shortcodes, like frm-stats, can't be used in the content parameter.

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Compare two fields in a View

Show a value when fields 391 and 390 are the same. Change these field IDs to match your own. Leave [id] as it is when you compare to a value in the same entry.

[frm-condition source=frm-field-value field_id=391 entry=[id] equals="[390]"]your content here[/frm-condition]
Since Formidable Forms 7.0, source=frm-field-value with entry=[id] gets the field value only for two kinds of users. One is anyone who can view entries in the admin area, which includes administrators. The other is the person who submitted that entry. Since 7.0.1, that includes a logged-out visitor, in the same browser, for 1 hour after they submit it. For everyone else, including other logged-out visitors, the value is empty. With an empty value, equals, like, greater_than, and less_than hide your content, and not_equal and not_like show it. This applies to every example in this section.

In a View that everyone can see, compare two fields from the same entry with a conditional statement instead. It works for every visitor and needs no code. The like, not_like, greater_than, and less_than options work the same way.

[if 391 equals="[390]"]your content here[/if 391]

If the field's values are meant to be public, you can also keep frm-condition and show the field's value to every visitor with the frm_field_value_requires_ownership hook. Use the ID from field_id (391 in this example).

Compare two fields with multiple selections

To compare a selected value in a Checkboxes or Radio Buttons field with a list of values, use the like parameter. This example checks whether the selected option is part of a list saved in a Hidden field, such as a list of member states.

  1. Add a Checkboxes field and fill it with your options using Bulk Edit Options. Bulk Edit Options has ready-made lists, such as Countries and U.S. States.
    Frm-condition Compare Multiple Checkboxes
  2. Add a Hidden field and set its Default Value to the list of options to match, separated by commas.
    Frm-condition Compare Multiple Hidden
  3. In your View, the shortcodes look something like this:
    [frm-condition source=frm-field-value field_id=304 entry=[id] like="[305]"]Is member state[/frm-condition]
    [frm-condition source=frm-field-value field_id=304 entry=[id] not_like="[305]"]Is not member state[/frm-condition]
    Replace 304 with your Hidden field ID and replace 305 with your Checkboxes field ID. Leave [id] as it is when you compare to a value in the same entry.

Compare two fields with numeric values

This example shows different content depending on which of two number field values is larger. Replace 210 and 211 with the ID or key of the fields to compare.

[frm-condition source=frm-field-value field_id=210 entry=[id] greater_than="[211]"]Show this result if greater than first field[/frm-condition]
[frm-condition source=frm-field-value field_id=210 entry=[id] less_than="[211]"]Show this result if less than first field[/frm-condition]

The first sample shows its content when field 210 is larger than field 211. The second shows its content when field 210 is smaller.

Compare a statistic

This example shows the statistic from the frm-stats shortcode only when it's higher than 10. Replace text-field with the ID or key of the field to count.

[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 the total_cost param in the URL or set in another shortcode. Only logged-in users see the message, because user_id=current gets the value from the current user's latest entry.

[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 whether 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 whether 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

Use a custom shortcode as the source to compare any value you can get with PHP, like the current user's role. These PHP examples create one:

Show users which forms they have filled out

When a user has many forms to fill out, show them which ones they've filled out and which ones they still need to.

For each form:

  • Create a stat to count the entries the user has submitted in that form. Here, 100 is the ID of a field in the form that always has a value, so it's never blank when the form is submitted. The stat looks something like this:
    [frm-stats id=100 type=count user_id=current]
    Tip: Check that your stat shows the correct values before moving to the next step.
  • Use the stat in frm-condition to check whether the user has filled out the form and to display a message:
    [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

To limit how many times each option can be selected, turn on Set option limits in the field's options. Learn more about how to set selection limits for options. Use the method below when you want to control the count and the HTML of each option yourself.

  1. In your form's Settings → Customize HTML, separate out each of your checkbox or radio options. Replace [input] with [input opt=1], and repeat for each option in the field.
  2. Create a stat to count how many times an option has been selected. (Optional) Test that it works before you continue. Your stat looks something like this:
    [frm-stats id=25 type=count 25="red"]
    Replace 25 with the ID of the Checkboxes or Radio Buttons field and replace "red" with the value of the option.
  3. Wrap each option in frm-condition so it shows only until it's been selected the maximum number of times. Use frm-stats as the source. Change the "red" in 25="red" to the value of the current option, and change 25 (in 2 places) to the ID of your field. Set the less_than parameter to the number of entries that people can submit. For example, to let people choose red 10 times, your shortcode looks something like this:
    [frm-condition source=frm-stats id=25 type=count 25="red" less_than=10][input opt=1][/frm-condition]
    You can use a different limit for each option.
  4. (Optional) To disable the option instead of removing it, add this shortcode after the shortcode above:
    [frm-condition source=frm-stats id=25 type=count 25="red" greater_than=9][input opt=1 disabled=disabled][/frm-condition]
    Set greater_than to 1 less than your less_than number, so the disabled option appears as soon as the option above is hidden.

Show users which subjects have no report submitted

In this example, one form collects subject names, and users submit reports for each subject in a second form. To show which subjects have no report, combine frm-stats with frm-condition.

  1. If you haven't yet, create a View of your first form.
  2. Create a stat that counts the entries in the second form for the current entry's subject. (Optional) Test that the stat shows the correct number of entries in the second form for every subject in the first form.
    [frm-stats id=100 type=count 100="[42]"]
  3. Insert the subject name field and the stat in the Listing Page Content box of your View. It looks something like this:
    Subject [42]: [frm-stats id=100 type=count 100="[42]"]
    Replace 100 with the ID of the Subject field in the second form and replace 42 with the ID of the subject field in the first form.
  4. Then remove the stat and use it in frm-condition to show the subject only when the stat is 0. Put the subject name and any other content you want to show about it inside frm-condition.
    [frm-condition source=frm-stats id=100 type=count 100="[42]" equals=0][42][/frm-condition]
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms