Hi Team,
I am trying to send a form data to external url using Gravity form. After the form is submitted it will generate a report id once I get that report id I want to submit another form with that report id after that I will get a pdf which I want to display on a page.
This is what I could get to so far it level one now just trying to send data first:
Option 1: Gives me a error
add_action(“gform_post_submission”, “post_to_rentfax”, 10, 2);
function post_to_rentfax($entry, $form){
if($form[“id”] != 12) //NOTE: replace number with your form id
return;
?>
<input type=“text” name=“address” value="<?php echo $entry["4.1"] ?>" />
<input type=“text” name=“city” value="<?php echo $entry["4.3"] ?>" />
<input type=“text” name=“state” value="<?php echo $entry["4.4"] ?>" />
<input type=“text” name=“zip” value="<?php echo $entry["4.5"] ?>" />
<input type=“select” name=“propertyType” value="<?php echo $entry["10"] ?>" />
<input type=“select” name=“bedrooms” value="<?php echo $entry["15"] ?>" />
<input type=“select” name=“bathrooms” value="<?php echo $entry["14"] ?>" />
<input type=“select” name=“squareFeet” value="<?php echo $entry["17"] ?>" />
</form>
<script type="text/javascript">
document.getElementById("form_to_rentfax").submit();
alert("form submitted");
</script>
<?php
}
When I use the code above it gives me this error: Uncaught DOMException: Blocked a frame with origin “Domainurl” from accessing a cross-origin frame.
Option 2: But doesn’t submit the data neither show any error.
add_action( ‘gform_after_submission_12’, ‘post_to_third_party’, 10, 2 );
function post_to_third_party( $entry, $form ) {
$post_url = ‘https://my.rentfaxpro.com/integration/report’;
$body = array(
‘reportCode’ => ‘RENT-REPORT’,
‘address’ => rgar( $entry, ‘4.1’ ),
‘city’ => rgar( $entry, ‘4.3’ ),
‘state’ => rgar( $entry, ‘4.4’ ),
‘zip’ => rgar( $entry, ‘4.5’ ),
‘propertyType’ => rgar( $entry, ‘10’ ),
‘bedrooms’ => rgar( $entry, ‘15’ ),
‘bathrooms’ => rgar( $entry, ‘14’ ),
‘squareFeet’ => rgar( $entry, ‘17’ ),
);
print_r($body);
GFCommon::log_debug( 'gform_after_submission_12: body => ’ . print_r( $body, true ) );
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
GFCommon::log_debug( 'gform_after_submission_12: response => ' . print_r( $response, true ) );
}
Any help would really be appreciated. Thank you all in advance.