Replies: 0
I’m trying to send the data of forminator to another url
I use this code to send data (the auth key has been removed due to security)
but the problem is that the form will not send the data and the network tab only show the thank you massage ajax
add_action(‘forminator_custom_form_after_save_entry’, ‘send_form_data_to_aiem’, 10, 2);
function send_form_data_to_aiem($entry_id, $form_id) {
if ($form_id !== 1200) {
return;
}
$entry = Forminator_API::get_entry($form_id, $entry_id);
if (!$entry) {
return;
}
$form_data = $entry->meta_data;
$data = [
[
"Key" => "Post_ID",
"Value" => $form_data['hidden-1']['value']
],
[
"Key" => "name",
"Value" => $form_data['name-1']['value']
],
[
"Key" => "surname",
"Value" => $form_data['name-2']['value']
],
[
"Key" => "email",
"Value" => $form_data['email-1']['value']
],
[
"Key" => "telephone",
"Value" => $form_data['phone-1']['value']
],
[
"Key" => "time_to_recontact",
"Value" => $form_data['text-1']['value']
],
[
"Key" => "message",
"Value" => $form_data['textarea-1']['value']
]
];
if (!empty($form_data['payment']['value'])) {
$data[] = [
"Key" => "online_payment",
"Value" => $form_data['payment']['value']
];
}
$body = json_encode(['data' => $data]);
$args = [
'body' => $body,
'headers' => [
'Authorization' => 'Bearer ',
'Content-Type' => 'application/json',
],
'timeout' => 60,
];
$url = 'https://www.gestionaleaiem.it/corsi/NewRequest';
$response = wp_remote_post($url, $args);
if (is_wp_error($response)) {
error_log('Forminator data sending error: ' . $response->get_error_message());
}
}