4
我使用wordpress 3.8和聯繫表格7插件與聯繫表格7分機擴展。wordpress contactform7防止重複字段值提交
我要檢查現有的電子郵件,我做對的functions.php鉤(alter_wpcf7_posted_data)如下提交:
function alter_wpcf7_posted_data($data) {
global $wpcf7;
if(email_exists($_POST['mail'])) {
$data = array();
}
return $data;
}
add_filter("wpcf7_posted_data", "alter_wpcf7_posted_data");
這個鉤子拋出我一個錯誤的來源,但不保存數據。
基本上,如果email_exists()返回true,我希望不保存數據並在表單上拋出驗證錯誤。
有誰知道如何防止表單提交。
注意:我沒有使用AJAX表單提交。
請指教。謝謝!