Gravity Forms Conditional Shortcode (2024)

Gravity Forms Conditional Shortcode (1)Jordan Smith

/Updated August 16, 2022 /77 Comments

Use the Gravity Forms Conditional Shortcode to display conditional content in your Gravity Form confirmations, notifications or HTML fields (with the GP Preview Submission perk).

Gravity Forms Conditional Shortcode (2)

December 6, 2016: Removed "not_equal" from the list of conditions. Props to Brad Nance!

Did you know that Gravity Forms provides a handy shortcode that allows you to display different content depending the data the user has entered in their submission? It’s a bit of a hidden gem.

How does it work? The shortcode allows you to create a condition (based on user input) that will evaluate to true or false. If the condition is true, the content within the shortcode will be displayed. If it is false, the content will not be displayed.

Gravity Forms’ conditional shortcode can be used anywhere WordPress shortcodes are supported. In the WordPress Classic Editor, you’ll have to decide where to slot in shortcodes yourself; if you’re using WordPress 5 or later you can simply drag in a shortcode block widget to wherever it looks best on the page you’re editing.

Here’s a list of the most useful locations:

  • Notifications
  • Confirmations
  • HTML Fields
    with the Gravity Forms Preview Submission perk
  • WordPress Post Content
    with Gravity Forms Post Content Merge Tags perk
  • Post Content Template and Post Title Content Template
    available via the Post Title and Post Body field settings respectively, more info

Quick Example

You have a few products that users can request additional information about. The user selects the product they’d like to learn more about using radio buttons on a simple Gravity Forms form.

You can use conditional shortcodes on the default confirmation to display a bit of information about the selected product.

This is what the above confirmation would generate if “Gravity Perks” was selected.

Usage Instructions

Let’s have a look at the different parameters that are available to the conditional shortcode. You can copy and paste the template Gravity Forms shortcode below. Fill in the values for each parameter as needed.

[gravityforms action="conditional" merge_tag="" condition="" value=""]Content you would like to conditionally display.[/gravityforms]

Parameters

  • action (string) (required)

    The action that will be performed. Use conditional for conditional shortcodes.

  • merge_tag (string) (required)

    Specify the merge tag to be evaluated by the condition and the value.

    You can find a full list of form-specific merge tags while editing a notification or confirmation to the right of the content editor. It looks like this: Gravity Forms Conditional Shortcode (7)

  • condition (string) (required)

    Enter the condition to be used to test the content of the merge tag with the value you specify. Possible conditions include:

    • isnot
    • is
    • greater_than
    • less_than
    • contains
    • starts_with
    • ends_with
  • value (string) (required)

    The value that will be compared against the merge_tag based on the condition.

The final “parameter” is the content. This is represented by any text you include inside the opening [gravityforms] and closing [/gravityforms] form shortcode tags. This text can include almost anything; from HTML to Gravity Forms merge tags.

Examples

Show Content Only if Value Exists

[gravityforms action="conditional" merge_tag="{My Field:1}" condition="isnot" value=""]My Field Label: {My Field:1}[/gravityforms]

Display User-requested Information

[gravityforms action="conditional" merge_tag="{More information on Gravity Perks:1}" condition="is" value="Gravity Perks"]<a href="http://gravityperks.com">Take your forms to another universe with Gravity Perks!</a>[/gravityforms]

Spacing Issue with Multiple Shortcodes

If you are using multiple conditional shortcodes, you may notice some spacing issues when unmet conditionals display nothing. You can fix these issues with one of two methods.

  1. Collapse the shortcodes down so that there is no whitespace between shortcodes.
  2. Select “Disable Auto-formatting” (when available) and wrap everything in tags.

Nested Conditional Shortcodes

Conditional shortcodes can be nested to achieve more complex logic. Nesting the shortcodes requires using both the plural [gravityforms] and singular [gravityform] shortcode to function. For example:

[gravityforms action="conditional" merge_tag="{:3}" condition="greater_than" value="10"][gravityform action="conditional" merge_tag="{:3}" condition="less_than" value="30"]Your value is greater than 10 less than 30[/gravityform][/gravityforms]

Taking It Further

Preview Submission

With Gravity Forms Preview Submission, conditional shortcodes can be used within HTML fields on your form. Typically, Preview Submission is used to display merge tag values in your form, but it also adds support for conditional shortcodes.

This perk also adds support for inserting entry-based merge tags in a field’s “Default Value” setting. This perk can also be used to populate data entered on previous pages of the form to latter pages of the form, meaning that you could display conditional shortcode data at a later stage in the form submission process.

Post Content Merge Tags

Using Gravity Forms Post Content Merge Tags, conditional merge tags can be used in WordPress post content. Not only can you display merge tag values in the content, you can also show content on confirmation pages based on user-submitted values.

The upshot of this is that you can create personalized submission pages that maintain consistent styling across your WordPress website but are populated with data from users’ form submissions. This also allows you to implement persistent confirmation pages, meaning users can be sent an email with the confirmation page URL which they can save for future reference.

Both Preview Submission and Post Content Merge Tags are part of Gravity Perks, a suite of WordPress plugins that dramatically extend the functionality of Gravity Forms in all kinds of wonderful ways.

Gravity Forms Conditional Shortcode (10)

Advanced Conditional Shortcodes

One limitation of the default conditional shortcode is that it only allows for a single condition to control what is displayed. If you want to display content based on the values from multiple form fields, you need an alternative solution. That’s why we built a simple Gravity Forms plugin to add support for multiple conditions in a single solution.

Using the plugin, you can display content based on multiple conditions – for example, a user looking for information on cars for sale might first select the vehicle type from a dropdown (SUV, pickup, etc), and then the specific model from a checkbox conditional on the first answer. The advanced Gravity Forms shortcode will then populate the confirmation message with the information specific to the specific combination in the user’s form submission. You can add on as many conditions as you can think of – it’s up to you!

More on Gravity Forms Shortcodes

Learn more about other types of Gravity Forms Shortcodes, parameters used for each, and how to get started using shortcodes through our comprehensive guide to Gravity Forms shortcodes.

How’d we do?

There are so many ways to use Gravity Forms’ conditional shortcodes. We’d love to hear how you are using them. Let us know in the comments below.

For more information, check out Gravity Forms’ documentation for conditional shortcodes.

Did this resource help you do something awesome with Gravity Forms?

Then you'll absolutely love Gravity Perks; a suite of 47+ essential add-ons for Gravity Forms with support you can count on.

View All PerksBuy Now

Tags: gp preview submission, shortcode

  1. Gravity Forms Conditional Shortcode (11)

    Socolov`March 31, 2024 at 3:09 am

    Hello friends!Is it possible to somehow show the results of the field filled with the user {Field: 3} from the form {scope = “form” id = “9”} in the shortcode?

    Reply

    1. Gravity Forms Conditional Shortcode (12)

      DarioStaffApril 1, 2024 at 12:16 pm

      Hi, yes, that should be possible testing for an empty value in Field ID 9.

      [gravityforms action="conditional" merge_tag="{FIELD_NAME:9}" condition="isnot" value=""]Shows the value of Field ID 9: {FIELD_NAME:9}[/gravityforms]

  2. Gravity Forms Conditional Shortcode (13)

    HamzaSeptember 13, 2023 at 9:33 pm

    how can I add a shortcode condition on the HTML field?

    For example Like this:

    [gravityforms action="conditional" merge_tag="{ISDE Subsidie Kiezen (Checkbox):16}" condition="is" value="Dak- of zolder/vlieringvloerisolatie"]

    @{Dak:28}

    @{Dak:28:price}

    @{Jaar:49:label}@{Jaar:49}

    @{Aantal:42:label}@{Aantal:42}

    @{type:53:label}@{type:53}

    [/gravityforms]

    Please let me know if this is possible Also I really appreciate it if you suggest an alternate solution.

    I’m eagerly waiting for the response!

    Reply

    1. Gravity Forms Conditional Shortcode (14)

      Samuel BassahStaffSeptember 20, 2023 at 5:45 am

      Hi Hamza,

      You’ll need to use our Advanced Conditional Shortcode plugin for this. You’ll also need to use the “contains” condition in place of “is” because this is a checkbox field.

      I hope this helps.

      Best,

  3. Gravity Forms Conditional Shortcode (15)

    JamesFebruary 10, 2023 at 2:21 pm

    I’m looking to see if this can be the solution we want to display data from a form in posts and articles.

    We have a table of positions names like “President,” “name” and “email”

    Can the plugin be used to show the Name and Email associated with the position?

    Our objective is to tell our posters to use a shortcode like [gf1 “President” “name” “email”] that when equal to the supplied position (President), the shortcode would return the name of the person and their email from the GF entry?We’re using the basic version of GravityWiz now but having a clean way to return insertable info would make upgrading to the full license a no brainer.Hope you can help a sort of technical guy understand what this would look like. Might need to hire someone to do the first one or two so we can do the rest.Thanks

    Reply

    1. Gravity Forms Conditional Shortcode (16)

      DarioStaffFebruary 13, 2023 at 5:33 am

      James,

      We’ve already followed up via email. To display Entry data on a Post/Page I would suggest checking out Entry Blocks Perk.

      Best,

  4. Gravity Forms Conditional Shortcode (17)

    navidAugust 31, 2022 at 4:39 am

    Hello, I want a user – example: it is possible to use only English letters in the name field ؟!

    Reply

    1. Gravity Forms Conditional Shortcode (18)

      Samuel BassahStaffAugust 31, 2022 at 7:35 am

      Hi Navid,

      I’m not really tracking your question very well. Can you provide more information on your request?

      Best,

  5. Gravity Forms Conditional Shortcode (19)

    BenJune 27, 2022 at 10:21 am

    Hey thanks for this,Are you able to please help me with this?I currently have a form that users can choose to submit their address or not.

    So in the notification emails, i currently have all the address merge tags added in (e.g. {Address (Street Address):276.1}, {Address (Address Line 2):276.2}, {Address (City):276.3}, {Address (State / Province):276.4}, {Address (ZIP / Postal Code):276.5}, {Address (Country):276.6})

    But since I added in the comma’s, if they don’t add in their address, i just get a bunch of comma’s in the email and a large white space.

    How/Can i make all them conditional so that if there is no address filled in, it removes the comma’s and blank space?

    Reply

    1. Gravity Forms Conditional Shortcode (20)

      Samuel BassahStaffJune 27, 2022 at 10:53 am

      Hi Ben,

      The shortcode below should work for you.

      [gravityforms action="conditional" merge_tag="{:276.1}" condition="isnot" value=""] {:276.1}, [/gravityforms][gravityforms action="conditional" merge_tag="{:276.2}" condition="isnot" value=""] {:276.2}, [/gravityforms][gravityforms action="conditional" merge_tag="{:276.3}" condition="isnot" value=""] {:276.3}, [/gravityforms][gravityforms action="conditional" merge_tag="{:276.4}" condition="isnot" value=""] {:276.4}, [/gravityforms][gravityforms action="conditional" merge_tag="{:276.5}" condition="isnot" value=""] {:276.5}, [/gravityforms][gravityforms action="conditional" merge_tag="{:276.6}" condition="isnot" value=""] {:276.6}, [/gravityforms]

      I hope this helps.

      Best,

  6. Gravity Forms Conditional Shortcode (21)

    DannyPJanuary 9, 2022 at 6:10 pm

    can this be used in notification and gravityflow notification emails? Similar to Mailchimp Conditional Merge tags?

    Thanks

    Reply

    1. Gravity Forms Conditional Shortcode (22)

      Samuel BassahStaffJanuary 10, 2022 at 5:34 am

      Hi Danny,

      This should work in Notifications but I’m not really sure about Gravity Forms Notifications emails. You can give it a try and see if it works or not. In case it doesn’t work you can get in touch via our support form so we can forward this to our developers as a feature request.

      Best,

  7. Gravity Forms Conditional Shortcode (23)

    Amy DalrympleOctober 20, 2021 at 11:45 am

    Hello, I’m wondering if this kind of thing exists for use inside of form fields at all?

    I have two fields, Restaurant Address and Mailing Address. The mailing address already has a conditional statement attached (“is this field the same as the restaurant address?).

    I have additional fields for each to indicate a suite or apartment #.

    I have a final “mailing address + suite” field where I am using a live merge tags snippet to pull both values from both the original mailing address and the suite number field to concatenate the values.

    However, if the mailing address is the same as the restaurant address, I want to instead pull the values from the restaurant address and its suite number. Is that possible?

    I know you stated above that shortcodes don’t work in field descriptions/fields, but this is sort of what I’m getting at: (77/71 pertains to my mailing address fields, 72/70 pertains to the restaurant address fields)

    [gravityforms action="conditional" merge_tag="{:77}" condition="isnot" value=""]{:77} {:71}[/gravityforms][gravityforms action="conditional" merge_tag="{:77}" condition="is" value=""]{:72} {:70}[/gravityforms]

    Thanks for any hints in advance!

    Reply

    1. Gravity Forms Conditional Shortcode (24)

      Samuel BassahStaffOctober 20, 2021 at 11:59 am

      Hi Amy,

      This snippet wouldn’t work for your use case. If you have an active Gravity Perks License, you can get in touch with us via our support form with an export of your form and we would happy to dig into this further.

      Best,

  8. Gravity Forms Conditional Shortcode (25)

    RicardoFebruary 21, 2021 at 8:00 pm

    Hello!

    I created a system where a hidden number field will count how many checkboxes are selected in the form. I want, in the confirmation section, to display a specific message if 2 or more checkboxes are selected (aka, the number in the count number field is 2 or more). To do this i used the following code (keep in mind gravity forms is in another language for me):

    Global text, should appear every time

    [gravityforms action="conditional" merge_tag="{Número de caixas tipo 1:8}" condition="greater_than" value=2]You have selected 2 or more checkboxes.[/gravityforms]

    More global text

    When i submit the form, regardless of the value of the number field, i always get the message:“Oops! We could not locate your form.” (equivalent in English)I used the merge_tag tool as described in this article to make sure i was selecting the correct number field.Does anyone know why this happens?

    Thank you.

    Reply

    1. Gravity Forms Conditional Shortcode (26)

      Samuel BassahStaffFebruary 22, 2021 at 11:43 am

      Hi Ricardo,

      The shortcode you have is correct and should work if the ID of the number field is 8. That said, looking at the error message you’re getting, I’m guessing this is actually related to something else and not the shortcode you’re using. If you’re a Gravity Perks Subscriber, you can get in touch via our support form, so we dig into this further.

      Best,

  9. Gravity Forms Conditional Shortcode (27)

    Kaden McLawsDecember 8, 2020 at 11:58 am

    For anyone wondering, the GF Docs shows you that the conditional shortcode can check to see if a particular option was chosen from a checkbox field like this:

    [gravityforms action="conditional" merge_tag="{Question:49:value}" condition="contains" value="A"]— This Text to show —[/gravityforms]

    But if you want to check to see if the user didn’t choose ANY options, it is as simple as changing condition=”is” and value=””.

    I had to find it by trial and error, hope this helps someone

    Reply

  10. Gravity Forms Conditional Shortcode (28)

    Ben HorleDecember 20, 2019 at 7:42 am

    Hi this is great! I’ve been using GF for ages and I didn’t know this was possible.

    May I ask if I wanted to only display the field if it was selectedWould it be possible to display the field selection in a more eye-friendly manner?I.e I have entered the conditional merge tag as follows for a radial button field

    [gravityforms action="conditional" merge_tag="{Buffet canape menu:91}" condition="isnot" Value=""]Buffet canape menu:{:91}[/gravityforms]

    This then outputs the as ” Buffet canape menu:Modern Classics ” in the notification.

    Would there be a way I could change this to something like (text within quotation marks being generated via the merge tag):thank you for enquiring about catering for a “Canape buffet” the “modern classics” menu is a great choice.

    I’d be really grateful if you wouldn’t mind helping me make my notifications look a bit less robot like.

    Thanks

    Ben

    Reply

    1. Gravity Forms Conditional Shortcode (29)

      Ben HorleDecember 20, 2019 at 8:13 am

      Also I am using GW conditional pricing to adjust my product price based on the volume of a product ordered.

      I tried to use the following code to stop the merge take showing should the product not have a price:

      [gravityforms action="conditional" merge_tag="{Creates and slates canapes signature (Price):96.2}" condition="isnot" Value="0.00"]Creates and slates canapes signature (Price){:96.2}[/gravityforms]

      I assume that I have got the “value” of “0.00” wrong? do I need to include the £ symbol?

      Thanks

      Ben

  11. Gravity Forms Conditional Shortcode (30)

    MichaelNovember 25, 2019 at 10:08 pm

    Can this be made to work in form field descriptions? I’m attempting to make this work in descriptions for correct pronoun use based on gender, such as “he” if the user selected “Male” in a previous dropdown field, and “she” if they selected “Female.” However, the shortcode is not being parsed and I’m certain I’ve typed the merge tag corrected. (FWIW, I do not have the menu to select merge tags available to me in this form field description box, and for those form inputs that I do have that option, merge tags for individual fields do not show anyway.)

    Reply

    1. Gravity Forms Conditional Shortcode (31)

      David SmithStaffDecember 17, 2019 at 10:09 am

      Shortcodes are not parsed in field descriptions. You might consider taking Populate Anything for a spin which has support for Live Merge Tags. These merge tags can be used in field descriptions and will update automatically whenever their corresponding field changes.

  12. Gravity Forms Conditional Shortcode (32)

    ColinSeptember 12, 2019 at 11:17 am

    Is there an short-code that will hide text if the condition is met rather than show it?

    Reply

    1. Gravity Forms Conditional Shortcode (33)

      David SmithStaffSeptember 13, 2019 at 1:01 pm

      Not exactly but if you reverse the logic of your condition you can use the existing shortcode.

  13. Gravity Forms Calculations | Red Earth Design, Inc.August 15, 2019 at 2:54 am

    […] can use conditionals inside notification emails in Gravity Forms, as explained here by Gravity Wiz. This could allow us to only display certain fields inside the notification instead of leaving […]

    Reply

  14. Gravity Forms Conditional Shortcode (34)

    Aaron RoesslerJuly 10, 2019 at 7:08 pm

    Is it possible to use multiple values separated by a comma in the “contains” logic?

    [gravityforms action="conditional" merge_tag="{Country:5}" condition="is" value="United States,Canada,Australia,Benin"]

    Reply

    1. Gravity Forms Conditional Shortcode (35)

      David SmithStaffJuly 11, 2019 at 7:38 am

      Hi Aaron, this is not supported but the our Advanced Conditional Shortcodes snippet will make create multiple conditions a lot easier.

  15. Gravity Forms Conditional Shortcode (36)

    arvindMay 16, 2019 at 2:01 pm

    Thanks for this article. It provides an insight. Another better way of presenting better notifications without touching a line of code would be using this Plugin:https://wordpress.org/plugins/wp-html-mail/On the Wp-Repo.Magically everything just falls into place and the spacing issue is solved almost automaticallyThanks

    Reply

  16. Gravity Forms Conditional Shortcode (37)

    DarrenApril 13, 2018 at 4:58 pm

    Does this conditional shortcode work in all areas where merge tags work? for example, the Query Strings area under Redirect Confirmations?

    Reply

    1. Gravity Forms Conditional Shortcode (38)

      David SmithStaffApril 13, 2018 at 9:18 pm

      Hi, Darren. No, I do not believe they are supported there.

  17. Gravity Forms Conditional Shortcode (39)

    Erik DeringMarch 26, 2018 at 10:22 am

    Anyone know why I don’t see this Perk (GF Conditional Shortcodes) listed on the Install Perks page?

    Reply

    1. Gravity Forms Conditional Shortcode (40)

      David SmithStaffMarch 26, 2018 at 11:11 am

      Hi Erik, this is not part of a Gravity Perks but rather a core Gravity Forms feature. If you have GF, you’re good to go. :)

    2. Gravity Forms Conditional Shortcode (41)

      Erik DeringMarch 26, 2018 at 1:55 pm

      ok, thanks. I purchased a license because I thought I need it. I don’t understand why my form is not showing the content based on the Value of the checkbox. David, I sent a Support request too about this. If you respond to that, can I give you WP access to look at it on a Staging Site?

  18. Gravity Forms Conditional Shortcode (42)

    SandraNovember 30, 2017 at 7:51 pm

    We have the latest stable (2.2.5.14) version of GravityForms installed and we cannot seem to get the conditions “is” and “contains” to work. “isnot” works fine and shows content, but the other two do not on several fields. Am I overlooking something or is this a bug?

    Many thanks for your help!

    Reply

    1. Gravity Forms Conditional Shortcode (43)

      David SmithStaffDecember 12, 2017 at 7:59 am

      Hi Sandra, I’d ping Gravity Forms support for this one.

  19. Gravity Forms Conditional Shortcode (44)

    Matt COctober 26, 2017 at 5:15 pm

    FYI, you state at the top that “December 6, 2016: Removed “not_equal” from the list of conditions. Props to Brad Nance!”and you did remove it from the list of conditions but did NOT remove it from the example code:

    Reply

    1. Gravity Forms Conditional Shortcode (45)

      David SmithStaffNovember 22, 2018 at 11:57 am

      Wow, Matt. Just seeing this… And I fell prey to my own mistake. Ouch! Removed.

  20. Gravity Forms Conditional Shortcode (46)

    Brad NanceDecember 1, 2016 at 4:23 pm

    Hi David,

    As always, your tutorials are incredibly helpful! Thanks again for posting these.

    I did notice one issue. It looks like the condition, “not_equal” no longer works. It seems to be been replaced by “isnot”.

    You might check this for yourself to see what results you get.

    Thanks!

    Reply

    1. Gravity Forms Conditional Shortcode (47)

      David SmithStaffDecember 6, 2016 at 9:03 am

      You are correct, Brad. Thanks for pointing this out. Article has been updated. :)

  21. Gravity Forms Conditional Shortcode (48)

    HarryOctober 15, 2016 at 8:43 pm

    Was there ever a solution to the empty fields when using merge_tags to display neat and orderly without various line breaks throughout conformations?

    Reply

  22. Gravity Forms Conditional Shortcode (49)

    JiriSeptember 4, 2016 at 2:06 pm

    Hi,I would like to ask for some help with gravity forms. I would like to use a value from field Total for my paypal button. The problem is that the value looks like this now: “100,00 €” and I need it in this format: “100.00”

    Only way I was able to come up with is to use conditional logic like this:

    [gravityforms action="conditional" merge_tag="{Price:1}" condition="is" value="100,00 €"]100.00[/gravityforms]

    And so on for every price option. This is very complicated and prone to make mistakes.

    Is there some simple way how to transform value from field Total to number that looks like this “100.00”?

    Thanks for any help.

    Reply

    1. Gravity Forms Conditional Shortcode (50)

      David SmithStaffSeptember 10, 2016 at 9:06 am

      I do not know of a way to do this easily. It’s definitely something I can see being useful. :)

    2. Gravity Forms Conditional Shortcode (51)

      GwénaëlDecember 29, 2017 at 6:25 am

      I agree with Jiri. It would be nice to make conditional shortcode work with prices.If I did not make any mistake, I can’t use the condtion “greater_than” with prices by example.Request for Gravity Forms :)

  23. Gravity Forms Conditional Shortcode (52)

    Mark ShekhterSeptember 1, 2016 at 2:22 pm

    Not sure if this is the right place to ask this, but working with conditional logic on some “list” type fields, but can not figure out how to target specific values in a particular column. Say, if I have a first list field called “Site Data” and two input areas of that list are “No. of Months” and “No. of Visitors”, then my merge tag looks like this: {Site Data:1:}, but it targets both “columns” and outputs them in a table format.How can I read value from “No. of Months” separately?

    Thank you in advance for any help.

    Reply

  24. Gravity Forms Conditional Shortcode (53)

    Sébastien DE CARVALHOApril 23, 2016 at 12:43 pm

    hello,Awesome blog, just discoved it yesterday, asking google about gravity tricks.the webdesign is really slick and efficient, i love it :)

    hi have a question for you wizzard :)

    is it possible to gave multiple condition that make appear an item (thanks to the shortcode) on confirmation page.i mean :

    this is the shortcode that i try to build, and testing, it does not work

    [content removed]

    i’ve only assigned A or B as a value in the form builderam i totaly wrong ?do you suggest another method for making this happen ?thanks for support

    Reply

    1. Gravity Forms Conditional Shortcode (54)

      Sébastien DE CARVALHOApril 23, 2016 at 12:45 pm

      basically, what i try to do is this :

      question 1 :-yes (value A)-no (value B)-i don’t know (value B)

      question 2 :-yes (value A)-no (value B)-i don’t know (value B)

      question 3 :-yes (value A)-no (value B)-i don’t know (value B)

      on the confirmation message, i show a notation based on answers given during the survey

      this

      AAA 5AAB 4ABB 3BBB 2BBA 3BAA 4

      ABA 4BAB 3

      :)

    2. Gravity Forms Conditional Shortcode (55)

      David SmithStaffApril 23, 2016 at 2:38 pm

      Hi Sébastien, no, it does not let you add multiple conditions to a single shortcode. You would need to nest them using a bit of hack. Use [gravityform action="conditional"] for one condition and then [gravityforms action="conditional"] (plural) for the nested condition.

    3. Gravity Forms Conditional Shortcode (56)

      Sébastien DE CARVALHOApril 23, 2016 at 3:06 pm

      Thanks David, for the Answer.By nest, do you mean : Inside ?my english is limited.Thanks a lot anyway, ther’s a solution,You’re the wizard :)

    4. Gravity Forms Conditional Shortcode (57)

      Sébastien DE CARVALHOApril 24, 2016 at 2:37 am

      Just to followup,it works now, i used anoyher technique, because, it seems that nested conditions are not allowed with shortcode (senn this on gravity forum, but not 100% sure..)i give each field it’s own value by a number (unique). Meaning option label a = value 1, option label b = value 2, option label g= 7 and so on.

      Then, i add a number field to your form (admin visibilty only) and i enable calculation and use the merge tag drop down to insert my form fields to add them all up. This will produce a score. I can then use conditional logic based on this calculated number field to show/hide information either in the form via multiple HTML fields, or via multiple confirmations with conditions set to show based on this calculated number field.thanks for all

  25. Gravity Forms Conditional Shortcode (58)

    Rob SnowApril 17, 2016 at 4:12 pm

    HiThe guys at GravityForms told me to use this conditional to test if the one of two options for a signature field where empty and display the one with something in it, and not display anything for the empty one. However, this does not show anything at all.Any clues?

    Signed:

    [gravityforms action="conditional" merge_tag="{Digital Signature (First):9.3} {Digital Signature (Last):9.6}" condition="isnot" value=""][/gravityforms] [gravityforms action="conditional" merge_tag="{Signature:8}" condition="isnot" value=""][/gravityforms]

    Reply

  26. Gravity Forms Conditional Shortcode (59)

    Carolyn WilsonMarch 30, 2016 at 4:06 am

    Well it looks like the comment removed the HTML. Please bear with me while I experiment:

    [gravityforms action="conditional" merge_tag="{Update another card?:54}" condition="is" value="Yes"]\<tr\>\<td\>{Lowes Petroleum BP+ Card Number:26}\</td\>\<td\>{Maintenance:27}\</td\>\<td\>{Services Required:30}\</td\>\<td\>{Prompted for at POS::42}\</td\>\<td\>{Additional Notes::33}\</td\>\</tr\>[/gravityforms]

    Reply

  27. Gravity Forms Conditional Shortcode (60)

    Carolyn WilsonMarch 30, 2016 at 4:03 am

    Hi David,

    The confirmation code is great!

    I do have a problem with the conditional shortcode, though. It doesn’t show the relevant information. (The shortcode I am using is working OK in notification emails. Just not on the confirmation page.)

    An example is:

    [gravityforms action="conditional" merge_tag="{Update another card?:54}" condition="is" value="Yes"]{Card Number:26}{Maintenance:27}{Services Required:30}{Prompted for at POS::42}{Additional Notes::33}[/gravityforms]

    If I remove the shortcode, the confirmation page shows the empty table rows, up to 9 of them, which looks a bit messy. It would be ideal to hide the empty rows.

    I also tried running the lines together with no success, like so:

    [gravityforms action="conditional" merge_tag="{Update another card?:54}" condition="is" value="Yes"]{Lowes Petroleum BP+ Card Number:26}{Maintenance:27}{Services Required:30}{Prompted for at POS::42}{Additional Notes::33}[/gravityforms]

    Any thoughts on that would be terrific!

    (It’s a login access only form, so I can’t just give you the URL.)

    Thanks,Carolyn

    Reply

    1. Gravity Forms Conditional Shortcode (61)

      David SmithStaffMarch 30, 2016 at 7:57 am

      Hi Carolyn, if it’s working in your Notifications but not your Confirmation, it might be a GF bug. I’d reach out to GF Support.

    2. Gravity Forms Conditional Shortcode (62)

      Carolyn WilsonApril 3, 2016 at 6:36 pm

      Thanks, David. I had that thought about 2 hours ago. It makes sense. :)

      Carolyn

  28. Gravity Forms Conditional Shortcode (63)

    KatrinaJanuary 3, 2016 at 9:54 am

    Hello,

    I am unable to get my shortcodes to work as expected. Using the following code, where “aabbcc” and “xxyyzz” represents text, it seems to me that my “is” condition does not work. No matter whether the mergtag value is “people” or not, “aabbcc” gets sent in my notification. When i completely remove the “isnot” condition, then nothing gets sent at all. Do you know why this might be? Am i doing something wrong?

    Thank you in advance of your assistance.

    [gravityforms action="conditional" merge_tag="{roommatepref:24}" condition="isnot" value="people"]aabbcc[/gravityforms]

    [gravityforms action="conditional" merge_tag="{roommatepref:24}" condition="is" value="people"]xxyyzz[/gravityforms]

    Reply

    1. Gravity Forms Conditional Shortcode (64)

      David SmithStaffMarch 14, 2016 at 8:25 pm

      Hi Katrina, it’s been a while since you posted, but feel free to send me an export of your form. Email david at gravitywiz dot com.

  29. Gravity Forms Conditional Shortcode (65)

    Mark ShekhterDecember 10, 2015 at 4:58 pm

    Hi there!Fantastic plugin, tutorials and snipplets — thank you!Having trouble with “nesting” the shortcode. Here is the example of syntax I’m using:

     [gravityforms action="conditional" merge_tag="{Creative Type:44:value}" condition="is" value="1"][gravityforms action="conditional" merge_tag="{Creative Size:45:value}" condition="is" value="1"]CS DT NEW[/gravityforms][/gravityforms] [gravityforms action="conditional" merge_tag="{Creative Type:44:value}" condition="is" value="1"][gravityforms action="conditional" merge_tag="{Creative Size:45:value}" condition="is" value="2"]CS FP NEW[/gravityforms][/gravityforms]

    It’s not working. In my confirmation I see the actual text [/gravityforms] after my CS DT NEW text. What am I ding wrong?

    Thanks in advance for your help!

    Reply

    1. Gravity Forms Conditional Shortcode (66)

      David SmithStaffDecember 11, 2015 at 8:30 am

      Hey Mark… you’re right. The nested conditions don’t work as expected. I played around it with it and found a hack. GF used to use a [gravityform] (singular) shortcode before switching to the plural [gravityforms]. We can use that to our advantage here and nested a singular shortcode inside the plural. Example: http://pastie.org/private/qh1ootl6wninwqadsha

    2. Gravity Forms Conditional Shortcode (67)

      Mark ShekhterDecember 11, 2015 at 9:18 am

      Fantastic solution! Works like a charm!Thank you David :-)

    3. Gravity Forms Conditional Shortcode (68)

      AlexJune 10, 2017 at 7:01 am

      Hi David, Alex. I have a problem. I tried to nest the conditions, with two seem to work but with three no.Eg:[gravityforms action="conditional" merge_tag="{Field:value}" condition="is" value="x"][gravityform action="conditional" merge_tag="{Field:value}" condition="is" value="y"][gravityform action="conditional" merge_tag="{Field:value}" condition="is" value="z"]TEST[/gravityform][/gravityform][/gravityforms]It’s not work, I also tried with:[gravityforms action="conditional" merge_tag="{Field:value}" condition="is" value="x"][gravityform action="conditional" merge_tag="{Field:value}" condition="is" value="y"][gravityforms action="conditional" merge_tag="{Field:value}" condition="is" value="z"]TEST[/gravityforms][/gravityform][/gravityforms]but nothingDo you have any suggestions?Thanks in advance

    4. Gravity Forms Conditional Shortcode (70)

      AlexJune 10, 2017 at 8:09 am

      Thanks David,

      Where do I have to put the file?

      Thank you

    5. Gravity Forms Conditional Shortcode (71)

      AlexJune 10, 2017 at 10:33 am

      Hi David,I did so.I put the file in the folder \wp-content/plugins/gravityformsAfter that I did so[gravityform action="conditional" relation="all" value="{field1:2}" operator="is" compare="value1" value="{field2:3}" operator="is" compare="value2" value="{field3:4}" operator="is" compare="value3"]TEST[/gravityform]Is it right?It isn’t work :(

      ThanksAlex

  30. Gravity Forms Conditional Shortcode (72)

    RoseDecember 4, 2015 at 7:03 pm

    Is there a way to have multiple conditions or between x and y?

    Thanks so much!

    Reply

  31. Gravity Forms Conditional Shortcode (73)

    Matt CohenNovember 25, 2015 at 9:57 pm

    Is there any option for AND/OR conditionals?

    e.g.combined:IF (Field1 IS “A” ) OR (Field2 IS “A”) THEN { }

    IF (Field1 IS “A” ) AND (Field2 IS “A”) THEN { }

    Reply

    1. Gravity Forms Conditional Shortcode (74)

      David SmithStaffNovember 26, 2015 at 5:45 am

      Hi Matt, “OR” is not supported but you can do “AND” conditions by “nesting” the shortcode.

      [if field1 is A][if field2 is A]your content[/if][/if]

    2. Gravity Forms Conditional Shortcode (75)

      Matt CNovember 30, 2015 at 7:03 pm

      Thanks for the complete reply. I was wondering if nested conditionals were allowed – we should be able to make it all work that way.

      Thanks!

    3. Gravity Forms Conditional Shortcode (76)

      James DunnMarch 4, 2016 at 10:19 pm

      David.

      Great article and it answers the question I came upon in the past couple of days. A client wanted to have a variable notification sent out from a form submission where the text varied based on choices that the visitor chose. To accomplish this, I need a Boolean AND function.

      Above, you noted that this could be accomplished like this:

      [if field1 is A] [if field2 is A] your content [/if] [/if]

      However, I’m assuming that you actually mean what I’ve put in this PasteBin: http://pastebin.com/22KFMLZW

      Is that correct, or should I actually be using an “IF” statement?

      Thanks.

    4. Gravity Forms Conditional Shortcode (77)

      David SmithStaffMarch 6, 2016 at 4:25 pm

      Hi James, what you have is correct. The “if” was just to demonstrate the concept. Sorry for the confusion. :)

    5. Gravity Forms Conditional Shortcode (78)

      James DunnMarch 6, 2016 at 4:34 pm

      Thanks David.

      Looks like the nested ability no longer functions. Of course, I still could have goofed some code. I was nesting three consecutive sets so that may be why it doesn’t work either. LOL.

      Thanks for the clarification though.

      JDD

    6. Gravity Forms Conditional Shortcode (79)

      David SmithStaffMarch 8, 2016 at 12:09 pm

      Hi James, I believe it will work if nested on two deep and alternating usage of [gravityforms] (plural) vs [gravityform] singluar.

    7. Gravity Forms Conditional Shortcode (80)

      James DunnMarch 8, 2016 at 9:46 pm

      I tried the two deep and alternating (may have goofed something), but finally came up with a solution that functions perfectly for my needs – albeit unconventional. I ticked the box for “Show Values” on the two determining fields and assigned them numbers. Then, I created an “Admin Only” number field and added the values from the two fields. I used that result i a single [gravityforms] shortcode and it actually worked flawlessly. I went back to some old school coding that I used to do to accomplish that one, but I’m happy to say it worked fantastically.

      Thanks for all the knowledge you impart here David. :)

  32. Gravity Forms Conditional Shortcode (81)

    TylerAugust 31, 2015 at 11:34 pm

    A quick question if you’re able to help:

    I’m trying to set up conditional logic so that if the field’s result is:

    Less than 10, display “x”. Else,More than 9 & less than 50, display “y”. Else,More than 49, display “z”.

    I’m having trouble with that middle one that declares a range. There’s no “range” condition, and trying to wrap multiple greater_than and less_than conditionals together around a single piece of content seems to mess up other conditional statements that come after it.

    Is there a way to do this? The only solution I see is to use the “is” conditional as a discrete statement and copy it for each possible value in the range. Yikes!

    Reply

    1. Gravity Forms Conditional Shortcode (82)

      David SmithStaffSeptember 8, 2015 at 1:31 am

      I think your best bet is to change the order of your conditions.

      If less than 10: display xElse if more than 49: display zElse: display y

  33. Gravity Forms Conditional Shortcode (83)

    Richard BestJuly 20, 2015 at 10:44 pm

    Hi David, Jordan. Thanks for this. Is the ability to include conditionals in the post content template a new ability that has crept into a recent update of Gravity Forms? I ask because in the past this wasn’t possible. Thanks.

    Reply

    1. Gravity Forms Conditional Shortcode (84)

      David SmithStaffJuly 21, 2015 at 8:37 am

      Hi Richard, to be clear, the shortcode is not processed in the Post Content Template itself, but the merge tags are replaced and the shortcode is processed when viewing the post (post editor, post frontend).

  34. Gravity Forms Conditional Shortcode (85)

    PietJuly 10, 2015 at 3:56 am

    Brilliant, a gem indeed! Thanks so much for the write-up.

    Reply

    1. Gravity Forms Conditional Shortcode (86)

      David SmithStaffJuly 10, 2015 at 7:04 am

      Our pleasure, Piet. Glad you liked it.

Leave a Reply

Gravity Forms Conditional Shortcode (2024)
Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 5506

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.