我通过重力表单将表单数据发送给第三方。我试图找出如何处理XML响应,以便:
如果<IsValid></IsValid>
返回值True,则重定向到<Redirect></Redirect>
否则,如果返回False,则显示<ResponseDetail></ResponseDetail>
我知道它需要基于这样的事情:
add_action( 'gform_after_submission', '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' ),
);
GFCommon::log_debug( 'gform_after_submission: body => ' . print_r( $body, true ) );
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
GFCommon::log_debug( 'gform_after_submission: response => ' . print_r( $response, true ) );
}