提交特定表格后,Gravity Forms 将多个表格组合的条目数据发送给第三方
Gravity Forms sending entry data combined from multiple forms to third-party after submitting a specific form
我不熟悉重力形式的钩子。
我创建了 2 个注册流程表单,它们以单一模式显示,但在不同的 div 中调用。我想将这些数据从 2 个表单发送到第三方应用程序,使用 gform_after_submission 在提交特定表单(最后一个表单)后将条目数据发送到第三方。
但是这样做:
add_action( 'gform_after_submission_2', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
$post_url = 'http://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
将只允许我从指定的表单 ID 中获取输入字段。
我怎么可能从其他表格中获取条目,以便我可以将其包含并 post 给第三方 url?
提前致谢。
如果您将表单数据保存到同一个 post 中,也许您可以根据 post id
获取日期
因为您在 add_action 本身中指定了表单 ID,所以当提交 ID 为 2 的重力表单时,您只是在 运行 设置您的函数。如果您希望它 运行 用于多次提交,但随后将其限制为特定的表单 ID,那么更像这样:
add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
if( $form->id == 2 || $form->id == somenumber ) {
$post_url = 'http://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
}
如果您不处理该对象,则可能需要使用 $form['id']
。其中之一会起作用。缺点是您必须知道要使用的表单的 ID。当查看您创建的 table 表单时,很容易在后端找到它,但它就是这样...
我不熟悉重力形式的钩子。 我创建了 2 个注册流程表单,它们以单一模式显示,但在不同的 div 中调用。我想将这些数据从 2 个表单发送到第三方应用程序,使用 gform_after_submission 在提交特定表单(最后一个表单)后将条目数据发送到第三方。
但是这样做:
add_action( 'gform_after_submission_2', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
$post_url = 'http://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
将只允许我从指定的表单 ID 中获取输入字段。
我怎么可能从其他表格中获取条目,以便我可以将其包含并 post 给第三方 url?
提前致谢。
如果您将表单数据保存到同一个 post 中,也许您可以根据 post id
获取日期因为您在 add_action 本身中指定了表单 ID,所以当提交 ID 为 2 的重力表单时,您只是在 运行 设置您的函数。如果您希望它 运行 用于多次提交,但随后将其限制为特定的表单 ID,那么更像这样:
add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
if( $form->id == 2 || $form->id == somenumber ) {
$post_url = 'http://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
}
如果您不处理该对象,则可能需要使用 $form['id']
。其中之一会起作用。缺点是您必须知道要使用的表单的 ID。当查看您创建的 table 表单时,很容易在后端找到它,但它就是这样...