Я использую WordPress, я настроил в нем форму, но мои добавленные поля показывают пустое сообщение, хотя в нем есть данные ...
Проблема в этих трех полях: date, pax и cabin "остальное работает хорошо ... Вы можете проверить это изображение введите описание изображения здесь
add_action('wp_ajax_st_send_email_single_service', 'st_send_email_single_service');
add_action('wp_ajax_nopriv_st_send_email_single_service', 'st_send_email_single_service');
function st_send_email_single_service() {
$type_service = isset($_GET['type_service']) ? $_GET['type_service'] : '';
$name_service = isset($_GET['name_service']) ? $_GET['name_service'] : '';
$name_st = isset($_GET['name_st']) ? $_GET['name_st'] : '';
$email_st = isset($_GET['email_st']) ? $_GET['email_st'] : '';
$phone_st = isset($_GET['phone_st']) ? $_GET['phone_st'] : '';
$date = isset($_GET['date']) ? $_GET['date'] : '';
$pax = isset($_GET['pax']) ? $_GET['pax'] : '';
$cabin = isset($_GET['cabin']) ? $_GET['cabin'] : '';
$content_st = isset($_GET['content_st']) ? $_GET['content_st'] : '';
$email_owl = isset($_GET['email_owl']) ? $_GET['email_owl'] : '';
$status = 0;
$message = '';
$subject_st = $name_st . ' - ' . $email_st;
if (empty($name_st) || (empty($email_st)) || (empty($phone_st)) || (empty($date)) || (empty($pax)) || (empty($cabin)) || (empty($content_st))) {
$status = 0;
if (empty($name_st)) {
$message .= __('Please enter your name', ST_TEXTDOMAIN) . '<br>';
}
if (empty($email_st)) {
$message .= __('Please enter your mail', ST_TEXTDOMAIN) . '<br>';
}
if (empty($phone_st)) {
$message .= __('Please enter your phone', ST_TEXTDOMAIN) . '<br>';
}
if (empty($date)) {
$message .= __('Please enter the date of the trip', ST_TEXTDOMAIN) . '<br>';
}
if (empty($pax)) {
$message .= __('Please enter the number of persons', ST_TEXTDOMAIN) . '<br>';
}
if (empty($cabin)) {
$message .= __('Please enter your cabin requests', ST_TEXTDOMAIN) . '<br>';
}
if (empty($content_st)) {
$message .= __('Please enter your content', ST_TEXTDOMAIN) . '<br>';
}
echo json_encode(
array(
'status' => $status,
'message' => $message,
)
);
} else {
$status = 1;
$admin_email = st()->get_option('email_admin_address');
$body_email = "<html><body><h2>" . $subject_st . "</h2>";
$body_email .= "<strong>" . __('Type Service', ST_TEXTDOMAIN) . "</strong>: " . $type_service . "<br/>" .
"<strong>" . __('Name Service', ST_TEXTDOMAIN) . "</strong>: " . $name_service . "<br/>" .
"<strong>" . __('Name customer', ST_TEXTDOMAIN) . "</strong>: " . $name_st . "<br/>" .
"<strong>" . __('Email customer', ST_TEXTDOMAIN) . "</strong>: " . $email_st . "<br/>" .
"<strong>" . __('Phone customer', ST_TEXTDOMAIN) . "</strong>: " . $phone_st . "<br/>" .
"<strong>" . __('Trip Date', ST_TEXTDOMAIN) . "</strong>: " . $date . "<br/>" .
"<strong>" . __('Number of Persons', ST_TEXTDOMAIN) . "</strong>: " . $pax . "<br/>" .
"<strong>" . __('Cabin Requests', ST_TEXTDOMAIN) . "</strong>: " . $cabin . "<br/>" .
"<strong>" . __('Notes', ST_TEXTDOMAIN) . "</strong>: " . $content_st . "<br/></html></body>";
$multiple_to_recipients = array($email_owl, $email_st, $admin_email);
$subject = $subject_st;
$body = $body_email;
$headers = 'From:' . $name_st . "<" . $email_st . ">" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= 'Cc: ' . $admin_email;
$attachment = false;
add_filter('wp_mail_content_type', 'set_html_content_type_sent_email');
$check = wp_mail($multiple_to_recipients, $subject, $body, $headers, $attachment);
remove_filter('wp_mail_content_type', 'set_html_content_type_sent_email');
echo json_encode(
array(
'status' => $status,
'message' => __('Thank you for contacting us!<br>We will be in contact shortly.', ST_TEXTDOMAIN),
)
);
}
die();
}
Я пытался найти похожую проблему, но безрезультатно, любая помощь будет буду признателен
Это код формы
<!-- <h4 class="heading"><?php echo __( 'Inquirement', ST_TEXTDOMAIN ) ?></h4> -->
<div class="media form-st-send-mail">
<form class="st_send-mail-form" method="GET" action="">
<input type="hidden" name="type_service" value="<?php echo esc_attr($type_service);?>">
<input type="hidden" name="name_service" value="<?php the_title();?>">
<input type="hidden" name="email_owl" value="<?php echo esc_attr($email_owl);?>">
<div class="form-wrapper">
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="form-group">
<input type="text" required class="form-control" name="name_st" placeholder="<?php echo __('Name *',ST_TEXTDOMAIN);?>">
</div>
<div class="form-group">
<input type="email" required class="form-control" name="email_st" placeholder="<?php echo __('Email *',ST_TEXTDOMAIN);?>">
</div>
<div class="form-group">
<input type="tel" required class="form-control" name="phone_st" placeholder="<?php echo __('Phone',ST_TEXTDOMAIN);?>">
</div>
<div class="form-group">
<input type="date" required class="form-control" name="date" placeholder="<?php echo __('Trip Date *',ST_TEXTDOMAIN);?>">
</div>
<div class="form-group">
<input type="number" required class="form-control" name="pax" placeholder="<?php echo __('Number of Persons *',ST_TEXTDOMAIN);?>">
</div>
<div class="form-group st_note_send_email">
<textarea name="cabin" class="form-control" placeholder="<?php echo __('Cabin Requests *',ST_TEXTDOMAIN);?>" style=""></textarea>
</div>
<div class="form-group st_note_send_email">
<textarea name="content_st" class="form-control" placeholder="<?php echo __('Notes',ST_TEXTDOMAIN);?>" style=""></textarea>
</div>
</div>
</div>
<div class="text-center">
<input id="submit" type="submit" name="submit" class="btn btn-primary btn-green upper font-small sent-email-st" value="<?php echo __('Send',ST_TEXTDOMAIN);?>">
</div>
<div class="message-wrapper-sendemail mt30"></div>
</div>
</form>
</div>