dongnaopa6200 2017-05-08 03:35
浏览 23

复制Web钩子

EDITED AS I REALISED I HAD PASTED THE WRONG CODE Our previous website developer created the below code to post the entries of a Gravity Form submission from our website into our CRM

add_action( 'gform_after_submission_37', 'post_to_click_dimensions', 10, 2 );
function post_to_click_dimensions( $entry, $form ) {
$cd_visitorkey = '';
if(isset($_COOKIE["cuvid"])){
    $cd_visitorkey = $_COOKIE["cuvid"];
}

$post_url = 'http://analytics-au.clickdimensions.com/forms/h/aMvdWx4ZaEUCVF6HP8XR1o';
$body = array(
    'First Name' => rgar( $entry, '1' ), 
    'Last Name' => rgar( $entry, '2' ), 
    'Email' => rgar( $entry, '3' ),
    'Organisation Name' => rgar( $entry, '4' ),
    'Phone' => rgar( $entry, '17' ),
    'Postcode' => rgar( $entry, '13' ),
    'Contact' => rgar( $entry, '6' ),
    'LID' => rgar( $entry, '10' ),
    'ReferringPage' => rgar( $entry, '14' ),
    'I am interested in' => rgar( $entry, '16' ),
    'cd_visitorkey' => $cd_visitorkey
);

I would like to add the same functionality for a different form that uses slightly different fields but when I replicate the above code and insert into functions.php I get a syntax error. So I tweaked the code to the below which doesn't give a syntax error but doesn't post the fields to the CRM - ant idea how to make the two codes work together??

add_action( 'gform_after_submission_48', 'post_to_click_dimensions', 10, 2 );
function post_to_click_dimensions( $entry, $form ) {

$post_url = 'http://analytics-au.clickdimensions.com/forms/h/aKyxSmgLocUuqSn5iUMvsw';
$body = array(
    'First Name' => rgar( $entry, '2' ), 
    'Last Name' => rgar( $entry, '3' ), 
    'Email' => rgar( $entry, '4' ),
    'Phone' => rgar( $entry, '5' ),
    'Postcode' => rgar( $entry, '6' ),
                    'cd_visitorkey' => $cd_visitorkey
);

}

  • 写回答

1条回答 默认 最新

  • dongtang6718 2017-05-08 09:10
    关注

    You mentioned that you need to do the same functionality for different form.

    For that you need to mention the form Id inside the hook as mentioned below. In the current example it will work only for the ID=>48 gform. Place your form ID in place of 'formid' in the hook call.

    add_action( 'gform_after_submission_formid', 'post_to_click_dimensions', 10, 2 );
    function post_to_click_dimensions( $entry, $form ) {
            $cd_visitorkey = '';
            if(isset($_COOKIE["cuvid"])){
                 $cd_visitorkey = $_COOKIE["cuvid"];
            }
    
    $post_url = 'http://analytics-au.clickdimensions.com/forms/h/aKyxSmgLocUuqSn5iUMvsw';
    $body = array(
        'First Name' => rgar( $entry, '2' ), 
        'Last Name' => rgar( $entry, '3' ), 
        'Email' => rgar( $entry, '4' ),
        'Phone' => rgar( $entry, '5' ),
        'Postcode' => rgar( $entry, '6' ),
        'cd_visitorkey' => $cd_visitorkey
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?