Last active
December 15, 2015 19:39
-
-
Save miukimiu/5313077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Enviar email wp--> | |
<?php | |
$admin_email = get_settings('admin_email'); | |
$headers = 'From:'; | |
$message = "dear $name,\n\n"; | |
$email_teste = "teste@teste.com"; | |
wp_mail( $email_teste, 'Registo', $message, $headers); | |
?> | |
<form action="<?php the_permalink(); ?>" id="contact_form" method="post"> | |
<ul> | |
<li> | |
<label for="name">Name:</label> | |
<input type="text" name="name" id="name" value="" /> | |
<label class="error" for="name" id="name_error">Este campo é obrigatório</label> | |
</li> | |
<li> | |
<label for="email">Email</label> | |
<input type="text" name="email" id="email" value="" /> | |
<label class="error" for="email" id="email_error">Este campo é obrigatório</label> | |
</li> | |
<li> | |
<label for="comments">Message:</label> | |
<textarea name="comments" id="comments" rows="10" cols="10"></textarea> | |
<label class="error" for="comments" id="comments_error">Este campo é obrigatório</label> | |
</li> | |
<li> | |
<button type="submit" id="submit">Send email</button> | |
</li> | |
</ul> | |
<input type="hidden" name="submitted" id="submitted" value="true" /> | |
</form> | |
<script> | |
/* | |
Form Request a Demo | |
This is an ajax validator | |
*/ | |
jQuery(function() { | |
jQuery.data(document.body, 'ajaxUrl', '<?php echo admin_url('admin-ajax.php'); ?>'); | |
}); | |
jQuery(function() { | |
jQuery('.error').hide(); | |
jQuery("#submit").click(function() { | |
var name = jQuery("#name").val(); | |
if (name == "") { | |
jQuery("label#name_error").show(); | |
jQuery("input#name").focus(); | |
return false; | |
} | |
var email = jQuery("#email").val(); | |
if (email == "") { | |
jQuery("#email_error").show(); | |
jQuery("input#email").focus(); | |
return false; | |
} | |
var comments = jQuery("#comments").val(); | |
var dataString = 'name='+ name + '&email=' + email + comments; | |
jQuery.ajax({ | |
type: "POST", | |
url: jQuery.data(document.body, 'ajaxUrl' ), | |
data: dataString, | |
success: function() { | |
jQuery('#contact_form').html("<div id='message'></div>"); | |
jQuery('#message').html("<h2>Message sent!</h2>") | |
.append("<p>Read your email.</p>") | |
.hide() | |
.fadeIn(1500, function() { | |
jQuery('#message').append("<img id='checkmark' src='/images/check.png' />"); | |
}); | |
} | |
}); | |
return false; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment