0

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);

}
4

1 回答 1

0

弄清楚了。

'first_name' => $entry['7.3'], 'last_name' => $entry['7.6'],

7.3 和 7.6 是 $entry 对象的不正确索引。我只是使用 '7' 和 split 功能让它正常工作。

于 2014-01-12T00:49:03.520 回答