Не отправляется новое поле JS_form_city, все остальное гуд, что тут надо откорректировать?
<div class="formBlock__formItem">
<input id="JS_form_name" class="field" name="name" type="text" placeholder="Ваше имя" required>
</div>
<div class="formBlock__formItem">
<input id="JS_form_city" class="field" name="cityz" type="text" placeholder="Гражданство" required>
</div>
<div class="formBlock__formItem">
<input id="JS_form_phone" class="field phoneMask" name="phone" type="tel" placeholder="+7 (___) ___-__-__" required>
сама функция JS
и функция PHP
/* Забираем отправленные данные */
$client_fio = $_POST['client_fio'];
$client_city = $_POST['client_city'];
$client_mail = $_POST['client_mail'];
$post_data = array(
'post_title' => $client_fio,
'post_title' => $client_city,
'post_content' => $client_mail,
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'mail',
);
wp_insert_post( $post_data );
$params = array(
'role' => 'Administrator',
'number' => 10
);
$emails = [];
$uq = new WP_User_Query( $params );
if ( ! empty( $uq->results ) ) {
foreach ( $uq->results as $u ) {
$emails[] = $u->user_email;
}
/* Отправляем нам письмо */
$emailTo = $emails; //get_option( 'admin_email' );
$subject = 'Заявка';
$headers = "Content-type: text/html; charset=\"utf-8\"";
$headers .= 'From: My Name <myname@mydomain.com>' . "\r\n";
$mailBody = "$client_fio $client_city <br/> $client_mail <br/>";
wp_mail($emailTo, $subject, $mailBody, array(
'Content-type: text/html; charset=utf-8'
));
/* Завершаем выполнение ajax */
die();
}
add_action("wp_ajax_send_mail", "send_mail");
add_action("wp_ajax_nopriv_send_mail", "send_mail");