我已经编写了一个前端表单,可以发布到自定义帖子类型,我有一个用于电子邮件的表单输入字段,当表单发布到自定义帖子类型时,我希望在提交时将电子邮件发送到插入电子邮件输入的电子邮件地址。
有什么想法吗??
编辑这是我的代码(忘记了lol)
if(\'POST\' == $_SERVER[\'REQUEST_METHOD\'] && !empty( $_POST[\'action\'] ) && $_POST[\'action\'] == "new_booking") {
if(isset($_POST[\'submit\'])) {
$sucess = "We will contact you regarding this booking.";
$errors = "";
if(!empty($_POST[\'booking_name\'])) {
$booking_name = trim($_POST[\'booking_name\']);
} else {
$errors .= "<li>Please enter your name.</li>";
}
if(!empty($_POST[\'booking_email\'])) {
$booking_email = trim($_POST[\'booking_email\']);
} else {
$errors .= "<li>Please enter your email.</li>";
}
if(!empty($_POST[\'booking_address\'])) {
$booking_address = trim($_POST[\'booking_address\']);
} else {
$errors .= "<li>Please enter your address.</li>";
}
if(!empty($_POST[\'booking_phone\'])) {
$booking_phone = trim($_POST[\'booking_phone\']);
} else {
$errors .= "<li>Please enter your phone number.</li>";
}
if(!empty($_POST[\'booking_rooms\'])) {
$booking_rooms = trim($_POST[\'booking_rooms\']);
} else {
$errors .= "<li>Please enter number of rooms.</li>";
}
if(!empty($_POST[\'booking_adults\'])) {
$booking_adults = $_POST[\'booking_adults\'];
} else {
$errors .= "<li>Please enter number of adults.</li>";
}
if(!empty($_POST[\'booking_arrival\'])) {
$booking_arrival = trim($_POST[\'booking_arrival\']);
} else {
$errors .= "<li>Please enter an arrival date.</li>";
}
if(!empty($_POST[\'booking_departure\'])) {
$booking_departure = trim($_POST[\'booking_departure\']);
} else {
$errors .= "<li>Please enter a departure date.</li>";
}
$booking_requirements = trim($_POST[\'booking_requirements\']);
if(empty($errors)) {
$new_booking = array(
\'post_title\' => $booking_name,
\'post_status\' => \'publish\',
\'post_type\' => \'listings\',
\'booking_email\' => $booking_email,
\'booking_address\' => $booking_address,
\'booking_phone\' => $booking_phone,
\'booking_rooms\' => $booking_rooms,
\'booking_adults\' => $booking_adults,
\'booking_arrival\' => $booking_arrival,
\'booking_departure\' => $booking_departure,
\'booking_requirements\' => $booking_requirements
);
$pid = wp_insert_post($new_booking);
add_post_meta($pid, \'booking_email\', $booking_email, true);
add_post_meta($pid, \'booking_address\', $booking_address, true);
add_post_meta($pid, \'booking_phone\', $booking_phone, true);
add_post_meta($pid, \'booking_rooms\', $booking_rooms, true);
add_post_meta($pid, \'booking_adults\', $booking_adults, true);
add_post_meta($pid, \'booking_arrival\', $booking_arrival, true);
add_post_meta($pid, \'booking_departure\', $booking_departure, true);
add_post_meta($pid, \'booking_requirements\', $booking_requirements, true);
}
}
}
do\\u action(“wp\\u insert\\u post”,“wp\\u insert\\u post”);