Мне нужно получить значения этой формы , отображаемой в другой форме на другой странице .
PS. Вторая форма не CF7. Я полагаю, что динамическое расширение текста контактной формы 7 не будет работать.
Я уже попробовал следующее.
function save_cf7_data($cf)
{
$submission = WPCF7_Submission::get_instance();
// Get the post data and other post meta values.
if ($submission) {
session_start();
$posted_data = $submission->get_posted_data();
// Encode the data in a new array in JSON format
$data = json_encode(array(
"Property_Address" => "{$posted_data["Property_Address"]}",
"Email" => "{$posted_data["Email"]}",
"Phone" => "{$posted_data["Phone"]}",
));
// Finally send the data to your custom endpoint
$ch = curl_init(get_stylesheet_directory_uri() . '/second-form.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); //Optional timeout value
curl_setopt($ch, CURLOPT_TIMEOUT, 5); //Optional timeout value
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
add_action('wpcf7_before_send_mail', 'save_cf7_data');
Вопрос первый: Как передать URL-адрес второй формы на curl_init()
?
Вопрос второй: Как получить переменные в php-файле второй формы?