我正在使用wordpress。首先,我不会使用插件,因为有一些问题。所以我设计了一个表格。我的表单设计下面是index.php我的主题。
<form name="sentMessage" id="contactForm" validate action="mail.php" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" name="phone" class="form-control" placeholder="Your Phone *" id="phone" required data-validation-required-message="Please enter your phone number.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" name="messages" dirname="message" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl" name="action">Send Message</button>
</div>
</div>
</form>
在这种形式中,我正在调用mail.php。它去那里但不起作用。而且mail.php也没有触发
header()
我声明去了一个网址。在我的代码下面
if (isset($_POST['action'])) {
$args ['to'] = 'dasanjan.0211@gmail.com';
$args ['subject'] = $_POST['email'];
$args ['body'] = $_POST['messages'];
$args ['headers'] = $_POST['name'];
add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {
$new_wp_mail = array(
'to' => $args['to'],
'subject' => $args['subject'],
'message' => $args['body']
'headers' => $args['headers'],
);
return $new_wp_mail;
}
header("Location : http://www.google.com/");
}
答案 0 :(得分:0)
您必须像这样调用表单操作
action=<?php bloginfo('template_url'); ?>/mail.php"
因为WP中有一种模式可以调用表单操作。