Gravity Form Submission to Sharpspring
<?php
// the trick below is replacing the _4 with the ID of the form you want to post to Sharpspring.
// obviously you need to create the same form in Sharpspring to post to.
add_action( 'gform_after_submission_4', 'post_referral_to_sharpspring', 10, 2 );
// ------------------------------------------------------------------------
if ( ! function_exists( 'post_referral_to_sharpspring' ) ) :
/**
* Sends form data from Gravity form ID#4 to Sharpspring CRM via HTTP POST
* @param object $entry
* @param object $form
* @return mixed
*/
function post_referral_to_sharpspring( $entry, $form )
{
$post_url = 'https://touchmedspa.marketingautomation.services/prospector/save';
$body = array(
'field_76686337' => rgar( $entry, '3.3' ),
'field_76687361' => rgar( $entry, '3.6' ),
'field_76688385' => rgar( $entry, '1' ),
);
$body['companyprofileid__sb'] = 'szQyNbM0BwA';
$body['agentreferrer__sb'] = 'http://touchmedspa.com/';
$body['trackingid__sb'] = '201603_56fc076429b9b9e0708b501d';
$body['formid__sb'] = 'cf3fe7d0-0eb3-4a53-a32b-979006e30ea8';
$post_url .= '/' . $body['companyprofileid__sb'] . '/' . $body['formid__sb'];
write_log( 'gform_after_submission: url => ' . print_r( $post_url, true ) );
write_log( 'gform_after_submission: body => ' . print_r( $body, true ) );
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
write_log( 'gform_after_submission: response => ' . print_r( $response, true ) );
}
endif;
?>
First you will want to change
<?php
// change the _4 to whatever ID of the form you want to use.
add_action( 'gform_after_submission_4', 'post_referral_to_sharpspring', 10, 2 );
?>
The following variables need to be pulled from the original sharpspring form, I just preview the form and inspect it myself.
You will also need to map the form fields from SharpSpring to Gravity Forms.
<?php
$body['companyprofileid__sb'] = 'szQyNbM0BwA';
$body['agentreferrer__sb'] = 'http://touchmedspa.com/';
$body['trackingid__sb'] = '201603_56fc076429b9b9e0708b501d';
$body['formid__sb'] = 'cf3fe7d0-0eb3-4a53-a32b-979006e30ea8';
?>