如何在wordpress插件联系表7中验证当前服务器时间? [关闭]

问题描述 投票:-1回答:1
wordpress contact-form-7
1个回答
0
投票
想通!

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else", 15, 3); function wpcf7_do_something_else($cf7, &$abort, $submission) { $id = $cf7->id(); // id of your cf7 form if ($id == 3580) { $date = date_i18n( get_option( 'date_format' ) ); $date = explode(" ", $date); $day = $date[0]; $time = date_i18n( get_option( 'time_format' ) ); $time = explode(':',$time); $hour = intval($time[0]); //custom day and time validation if ( ( $day == 'Sunday' || $day == 'Saturday' ) || !( ( 5 <= $hour) && ($hour <= 20) ) || ( $day == "Friday" && $hour >= 20 ) ) { $abort = true; // &$abort reference $submission->set_status( 'validation_failed' ); $errMsg = "Your error message"; // custom error message $submission->set_response( $cf7->filter_message($errMsg) ); } } return $wpcf; }

希望这对某人有帮助:)    
© www.soinside.com 2019 - 2024. All rights reserved.