my objective is to submit values via POST of a contact form 7 to a redirected outside php page and echo those values.
The issue is when the page is redirected after the submission, the values seem to be lost unless i remove the JS and change the action Url of the form ending up removing all the contact form 7 features which i require (validation, email sent, etc..).
I tried multiple plugins such as contact form 7 to API and it only works via GET method which i don't want. I tried to get the posted values and transforming them into session but it's not working because i'm probably doing something wrong.
Here's the form: enter image description here
Here's the result that is supose to be shown: enter image description here
UPDATE:
Ok so i posted the function to fetch the posted data and the var_dump missing on the result php file.
Here's the fucntions.php
add_action( 'wpcf7_before_send_mail', 'send_post_values' );
if ($form_id == 7627) {
$user = $cf7->posted_data["user"];
$email = $cf7->posted_data["email"];
$country = $cf7->posted_data["country"];
//any code missing??
}
}
Here's the show-values.php
<?php
var_dump($_POST);
print_r($_POST);
echo "Name: " . $_POST["user"] . "<br>";
echo "Email: " . $_POST["email"] . "<br>";
echo "Country: " . $_POST["country"] . "<br>";
?>
And here's the JS i put on the edit page of wordpress for redirection
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'https://www.xxxxx.xxx/forms/show-values.php';
}, false );
The output is still missing: enter image description here
Not using any extra plugin besides cf7 at the moment.