Answer the question
In order to leave comments, you need to log in
How to include phpmailer library in wordpress?
I just can’t understand, there is a form:
There is a phpmailer library, I tried to do this:
var data = {
action : 'not_found_form',
found_form : sendForm
}
$.ajax({
type: "POST",
url: not_found_404.ajax_url,
data: data,
success: function(data) {
console.log(data);
},
error: function(xhr){
}
});
function scripts() {
if ( is_404() ) {
wp_enqueue_script( '404-form', get_template_directory_uri() . '404-form.js', array( 'jquery' ), '1', true );
wp_localize_script( '404-form', 'not_found_404', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
}
}
add_action( 'wp_enqueue_scripts', 'scripts' );
add_action('wp_ajax_not_found_form', 'form_not_found_page');
add_action('wp_ajax_nopriv_not_found_form', 'form_not_found_page');
function form_not_found_page() {
if ( isset($_POST['name'] ) ) {
$name = trim( strip_tags( $_POST['name'] ) );
}
if ( isset($_POST['phone'] ) ) {
$phone = trim( strip_tags( $_POST['phone'] ) );
}
ContactMailer::send( $name, $phone );
exit;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question