【问题标题】:Gravity Forms - gform_after_submission not working重力形式 - gform_after_submission 不起作用
【发布时间】:2014-01-11 23:21:01
【问题描述】:

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

}

【问题讨论】:

    标签: php wordpress gravity-forms-plugin


    【解决方案1】:

    想通了。

    'first_name' => $entry['7.3'], '姓氏' => $entry['7.6'],

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

    【讨论】:

      猜你喜欢
      • 2013-05-28
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 2015-05-26
      • 1970-01-01
      • 2013-09-22
      相关资源
      最近更新 更多