在我的页面中调用了gform_after_submission,但$entry和$form对象为空。有什么理由会发生这种情况吗?根据日志的输出,我知道代码可以运行,但不知道为什么$entry参数为空。
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);
}发布于 2014-01-12 08:49:04
我想通了。
'first_name‘=> $entry'7.3','last_name’=> $entry'7.6',
7.3和7.6是$entry对象的错误索引。我只是使用了'7‘和split函数来让它正常工作。
https://stackoverflow.com/questions/21069180
复制相似问题