gform_after_submission在我的页面中被调用,但$ entry和$ form对象为null。有什么理由会发生这种情况吗?基于日志的输出,我知道代码运行,但无法弄清楚为什么$ entry参数为null。
add_action('gform_after_submission_2', 'post_to_third_party', 10, 2);
function post_to_third_party($entry, $form) {
error_log("Posting comments form");
$post_url = 'https://api.club-os.com/prospects?clubLocationId=686';
$body = array(
'first_name' => $entry['7.3'],
'last_name' => $entry['7.6'],
'email' => $entry['6'],
'mobilePhone' => $entry['8']
);
error_log('Before Post to' . $post_url);
$args = array(
'headers' => array('Authorization' => 'Basic ' . base64_encode( 'username' . ':' . 'password' )),
'body' => $body,
'sslverify' => false
);
foreach ($body as $key => $value) {
error_log($value . " in " . $key . ", ");
}
$request = new WP_Http();
$response = $request->post($post_url, $args);
}
答案 0 :(得分:0)
想出来。
'first_name'=> $进入[ '7.3'], 'last_name'=> $条目[ '7.6'],
7.3和7.6是$ entry对象的错误索引。我只是使用了'7'和split函数来使它正常工作。