php 获取重力形式输入值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11164173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:53:00  来源:igfitidea点击:

Get gravity forms input values

phpformswordpress-plugingravity-forms-plugin

提问by Yamiko

How do i get the values of specific input elements inside the gform_after_submissionhook in Gravity Forms? I can get the labels with

我如何gform_after_submissionGravity Forms 中获取钩子内特定输入元素的值?我可以得到标签

foreach($form['fields'] as $k=>$v)
{
    $label=$form['fields'][$k]['label'];
}

but how do I get the values?

但我如何获得价值?

回答by McNab

Following the Gravity guidelines you set up the hook to call your own function - in the case below the function is after_submission().

遵循 Gravity 指南,您可以设置钩子来调用您自己的函数——在下面的例子中,函数是 after_submission()。

You can access the input values of individual form elements using their IDs like so;

您可以像这样使用它们的 ID 访问单个表单元素的输入值;

add_action("gform_after_submission", "after_submission", 10, 2);

function after_submission($entry, $form){

    $name = $entry["2"];
    $address = $entry["17"] . ', '. $entry["18"] .', '. $entry["19"];

}

The IDs are all there in the form fields title in the backend, just hover over each one and it'll give you the type and ID (ie 'Single Line Text: Field ID 2).

ID 都在后端的表单字段标题中,只需将鼠标悬停在每个字段上,它就会为您提供类型和 ID(即“单行文本:字段 ID 2”)。

http://www.gravityhelp.com/documentation/page/Gform_after_submission

http://www.gravityhelp.com/documentation/page/Gform_after_submission