我正在创建一个插件,在发送邮件之前挂钩Contact表单7,插件将检查邮件内容并确定邮件应该发送到哪个电子邮件。我的插件工作正常,但由于这个原因,联系表单7验证无效。每当我发送消息时,微调器一直在旋转,但邮件正在正常发送。只有成功或验证消息无效。
<?php
/*
Plugin Name: Email Filteration
Plugin URI: http://my-awesomeness-emporium.com
Description: a plugin to filter your message type
Version: 1.0
Author: Himanshu
Author URI: http://mrtotallyawesome.com
License: GPL2
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once ('email-filter-menu.php');
add_action( 'admin_menu', 'register_newpage' );
function register_newpage()
{
add_menu_page('Email Filter', 'Email Filter', 'administrator', 'custompage', 'user_input_data');
}
add_action( 'wpcf7_before_send_mail', 'cf7sr_verify_email_filter' );
function cf7sr_verify_email_filter( $cf7 )
{
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$user_name_data=get_option('EF_user_name_field');
$user_phone_data=get_option('EF_user_phone_field');
$user_subject_data=get_option('EF_user_subject_field');
$user_message_var=get_option('EF_user_message_field');
$user_f_word=get_option('EF_user_filter_words');
$words=explode(",",$user_f_word);
$message=$data[$user_message_var];
$name_field=$data[$user_name_data];
$phone_field=$data[$user_phone_data];
$subject_field=$data[$user_subject_data];
$string_union=$message." ".$name_field." ".$phone_field." ".$subject_field;
// $array_message=array("seo", "web");
// $words=array("seo", "responsive");
$array_message=preg_split("/( |,)/", $string_union);
$result=array_intersect(array_map('strtolower',$array_message), array_map('strtolower',$words));
if($result){
$to ='writercontent2017@gmail.com';
$subject = "Message from plugins";
$headerss = 'From: himanshucoolindia@gmail.com';
$sent = wp_mail($to, $subject, $message, $headerss);
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <himanshucoolindia@gmail>' . "\r\n";
mail($to,$subject,$message,$headers);
$submission->skip_mail = true;
//add_filter( 'wpcf7_form_response_output', 'wpse_form_response_output', 10, 4 );
$wpcf7 = WPCF7_ContactForm::get_current();
$wpcf7->skip_mail = true;
add_filter( 'wpcf7_skip_mail', '__return_true' );
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_form_response_output', 'wpse_form_response_output', 10, 4 );
}
}
function wpse_form_response_output( $output, $class, $content, $object )
{
return sprintf(
'<div class="wpcf7-response-output wpcf7-display-none wpcf7-mail-sent-ng"
role="alert" style="display: block;">%s</div>',
__( 'SOAP ERROR - Mail not sent!' )
);
}
?>
这里我包含了email-filter-menu.php文件,如果我对此进行评论,那么电子邮件验证开始工作但成功消息没有显示。