重力形式-条件合并标签-单个标签中有多个值 [英] Gravity Forms - Conditional merge tags - MULTIPLE Values in a single tag
问题描述
我在表单确认中使用条件合并标签短代码,如下所示: https://gravitywiz.com/gravity-forms-conditional-shortcode/
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.
因此,对于18岁以下的人,我会在消息中使用简码:
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]
对于55岁以上的人,我会在消息中使用简码:
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]
现在,我很难向18至55岁之间的人展示此消息.
Now I struggle to show the message to people who are between 18 - 55.
我正在尝试使用 condition ="is"
这样从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]
但这是行不通的.
有什么办法可以在同一个标签中使用多个值或指定 greater_than
和 less_than
之类的东西?
Is there any way I can use multiple values or specify something like is greater_than
and less_than
in the same single tag?
推荐答案
我有一个片段使Gravity Forms的条件短代码更加健壮:
I have a snippet that makes Gravity Forms' conditional shortcode a little more robust:
https://gist.github.com/spivurno/9db18385ed1d1f11a897bdfa8a1f2007
在主题的functions.php文件中使用此代码段后,您可以像这样编写逻辑:
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]```
这篇关于重力形式-条件合并标签-单个标签中有多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!