0
votes

I am using the Conditional Merge Tags shortcode in the form confirmation as found here: https://gravitywiz.com/gravity-forms-conditional-shortcode/

I've got a number field on the form where I ask people to input their age.

On the confirmation message, I'm using the merge tags to display a custom message based on the age input.

So for people who are younger than 18, I use shortcode with a message:

[gravityforms action="conditional" merge_tag="{my-field}" condition="less_than" value="18"]
You're too young.
[/gravityforms]

For people who are older than 55, I use shortcode with a message:

[gravityforms action="conditional" merge_tag="{my-field}" condition="greater_than" value="55"]
You're too old.
[/gravityforms]

Now I struggle to show the message to people who are between 18 - 55.

I'm trying to input multiple values from 18 to 55 with condition="is" like this:

[gravityforms action="conditional" merge_tag="{my-field}" condition="is" value="18, 19, 20, 21, ....... 54, 55"]
        You're the perfect age.
[/gravityforms]

But this doesn't work.

Is there any way I can use multiple values or specify something like is greater_than and less_than in the same single tag?

2

2 Answers

2
votes

I have a snippet that makes Gravity Forms' conditional shortcode a little more robust:

https://gist.github.com/spivurno/9db18385ed1d1f11a897bdfa8a1f2007

With this snippet in your theme's functions.php file, you could write the logic like so:

[gravityforms action="conditional" relation="all"
value="{myField}" operator="greater_than" compare="18"
value2="{myField}" operator2="less_than" compare2="55"]
    You're the perfect age.
[/gravityforms]```
1
votes

The conditional shortcode doesn't support multiple values or conditions at this time. However, you can create an additional confirmation for the 18-55 case, and use conditional logic on the confirmation itself.