Hello,
I am using add_action(‘gform_confirmation_3’, array($this, ‘custom_confirmation’), 10, 4); in a plugin to send form data to a 3rd party api and show the response in the confirmation. I have everything set up, but my entry is empty. When I error log the body the values are empty. Am I using the rgar() wrong? I’m passing in the field id value. Each of these fields are either text or dropdown fields. Ajax is set to true on the form. Not sure what else I may be missing. Any help would be appreciated!
function custom_confirmation($confirmation, $entry, $form, $ajax) {
//emptied get token function from here as it's not important to the info below
// Use Token In Actual Call
$post_url = $token['instance_url'] . '/services/apexrest/FindAccountRepService/V1';
$args = array(
'acctInfo' => array(
'name' => rgar( $entry, '1' ),
'country' => rgar( $entry, '10' ),
'postalCode' => rgar( $entry, '7' ),
'state' => rgar( $entry, '9' ),
'city' => rgar( $entry, '8' ),
'productLine' => rgar( $entry, '4' ),
'industryType' => rgar( $entry, '5' )
)
);
$body = json_encode($args);
error_log(print_r($body, true));
GFCommon::log_debug( 'gform_confirmation: body => ' . print_r( $body, true ) );
$request = new WP_Http();
$response = $request->post( $post_url, array(
'headers' => array(
'Authorization' => $token['token_type'] . ' ' . $token['access_token'],
'Cookie' => 'BrowserId=unsAxTdPEeyddq_3TSkKyg; CookieConsentPolicy=0:0; LSKey-c$CookieConsentPolicy=0:0',
'Content-Type' => 'application/json'
),
'body' => $body )
);
GFCommon::log_debug( 'gform_confirmation: response => ' . print_r( $response, true ) );
$confirmation .= print_r( $response, true );
return $confirmation;
}