Ajax-Kontaktformular

Ich habe ein benutzerdefiniertes Kontaktformular, das ich über Ajax zu verarbeiten versuche. Ich bin ein bisschen Neuling in Ajax und mehr mit WordPress. Ich habe es gebaut, aber es sendet die E-Mail nicht und ruft “0” ab.

PHP-function:

add_action('wp_ajax_ajaxContacForm', 'ajaxContacForm'); add_action('wp_ajax_nopriv_ajaxContacForm', 'ajaxContacForm'); //Ajax contact form filter function function ajaxContacForm() { if(!$_POST) exit; global $t_one_opt; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $comments = $_POST['comments']; if(trim($name) == '') { echo '
Please enter your name.
'; exit(); } else if(trim($email) == '') { echo '
Please enter a valid email address.
'; exit(); } else if(trim($phone) == '') { echo '
Please enter a valid phone number.
'; exit(); } else if(!is_numeric($phone)) { echo '
Phone number can only contain digits.
'; exit(); } else if(!isEmail($email)) { echo '
You have enter an invalid e-mail address,please try again.
'; exit(); } if(trim($comments) == '') { echo '
Please enter your message.
'; exit(); } if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); } // Configuration option. // Enter the email address that you want to emails to be sent to. // Example $address = "joe.doe@yourdomain.com"; //$address = "example@themeforest.net"; //global $t_one_opt; $address = $t_one_opt['contact_email']; // Configuration option. // ie The standard subject will appear as, "You've been contacted by John Doe." // Example, $e_subject = '$name . ' has contacted you via Your Website.'; $e_subject = 'You\'ve been contacted by ' . $name . '.'; // Configuration option. // You can change this if you feel that you need to. // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here. $e_body = "You have been contacted by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL; $e_content = "\"$comments\"" . PHP_EOL . PHP_EOL; $e_reply = "You can contact $name via email, $email or via phone $phone"; $msg = wordwrap( $e_body . $e_content . $e_reply, 70 ); $headers = "From: $email" . PHP_EOL; $headers .= "Reply-To: $email" . PHP_EOL; $headers .= "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL; $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL; if(mail($address, $e_subject, $msg, $headers)) { // Email has sent successfully, echo a success page. echo "
"; echo "
"; echo "

Wohoooo ! Well done

"; echo "

Thank you $name, your message has been submitted to us.

"; echo "
"; echo "
"; } else { echo 'ERROR!'; } }

jQuery-function:

 jQuery(document).ready(function ($) { // Send email jQuery('#contactform').submit(function () { $("#message").slideUp(750, function () { $('#message').hide(); $('#submit') .after('') .attr('disabled', 'disabled'); jQuery.ajax({ type:"POST", url: "http://www.codetocode-developments.com/t-one/wp-admin/admin-ajax.php", data: { action: ajaxContacForm, name: $('#name').val(), email: $('#email').val(), phone: $('#phone').val(), comments: $('#comments').val(), }, success:function (data) { document.getElementById('message').innerHTML = data; $('#message').slideDown('slow'); $('#contactform img.loader').fadeOut('slow', function () { $(this).remove() }); $('#submit').removeAttr('disabled'); if (data.match('success') != null) $('#contactform').slideUp('slow'); } }); }); return false; }); }); 

Was mache ich schlecht?

Solutions Collecting From Web of "Ajax-Kontaktformular"