what I want to do, is when user submits my gravity form, the data is sent to another wordpress platform where is also a form with the same fields. The data should be entered and submitted automatically and user should be redirected to Thank you page. I have read about cURL and GF Web API, but I haven't got them to work. I have made gform_after_submission HOOK where I have this code
add_action("gform_after_submission_7", "after_submission");
function after_submission($entry, $form){
//All the code that processes your form goes here
$curl_handle = curl_init();
//siia tuleb panna value asemele õiged väärtused
$post_url = 'http://ift.tt/1B1QaRH';
$body = array(
'info' => rgar ( $entry, '5' ),
'name' => rgar ( $entry, '25' ),
'email' => rgar ( $entry, '2' ),
'submit' => 'true',
);
$data ='"info='.$body['info'].'&nimi='.$body["nimi"].'&email='.$body["email"].'"';
$url = "http://ift.tt/1B1QaRH";
curl_setopt ($curl_handle, CURLOPT_URL,$url);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data);
curl_setopt( $curl_handle, CURLOPT_SSL_VERIFYPEER, false ); //so we can post to https
$result = curl_exec ($curl_handle);
curl_close ($curl_handle);
//then once you have processed the form you can redirect to a success page
}
The page, where it should POST form data has these lines
jQuery(document).ready(function() {
if ($("#input_9_1").length) {
console.log("<?php echo $_GET['nimi']; ?>");
$('#input_9_1').val("<?php echo $_POST['info']; ?>");
$('#input_9_2').val("<?php echo $_GET['nimi']; ?>");
$('#input_9_3').val("<?php echo $_POST['email']; ?>");
//$('#input_9_4').val(<?php echo $_POST["mobiil"]; ?>);
}
<?php
if (isset($_POST['submit'])) {
echo "$('#gform_submit_button_9').click();";
}
?>
});
But right now when user submits my form, he is automatically redirected to thank you page and it doesn't seem to POST and submit this other form, where I am trying to send my data.
Can someone help me with this, I have been trying to solve this for the entire day now and it still won't work. I might do this completely the wrong way, but maybe someone can help me with this.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire