I am using WP_MAIL to submit a contact form from my wordpress website. I have two files, one for the HTML form and one for the PHP function. When i hit submit however the function doesn't seem to fire. I have tested wp_mail and it is working. The strange thing is, this function was workign on Monday and now it is not.
Here is a basic version of my HTML and the full PHP function.
<form class="form-horizontal" action="" method="POST">
<input type="text" class="form-control" name ="name" placeholder="your name">
<input type="text" class="form-control" name ="email" placeholder="your email">
<input type="text" class="form-control" name ="number" placeholder="your number">
</form>
<?php
add_action('wp', 'send_my_awesome_form');
function send_my_awesome_form(){
if (!isset($_POST['submit'])) { return; }
// get the info from the from the form
$form = array();
$form['name'] = $_POST['name'];
$form['number'] = $_POST['number'];
$form['email'] = $_POST['email'];
// Build the message
$message = "Name :" . $form['name'] ."\n";
$message .= "Number :" . $form['number'] ."\n";
$message .= "Email :" . $form['email'] ."\n";
//set the form headers
$headers = 'From: The Website';
// The email subject
$subject = 'Booking Request';
// Who are we going to send this form too
$send_to = '[email protected]';
if (wp_mail( $send_to, $subject, $message, $headers ) ) {
wp_redirect('http://www.urltogoto.com'); exit;
}
}
?>