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_48', '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
);

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

Read more here: Replicating web hook


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: