使用 Flamingo 和 Contact Form 7 进行服务器端验证
Server Side Validation with Flamingo and Contact Form 7
我有最后一个 WordPress 站点,安装了最后一个联系表 7 和火烈鸟插件。
这是一个简单的表单,有一个电子邮件字段和一个消息字段。
我想查询数据库以检查电子邮件是否已经将之前的消息发送到我的站点。
Is this possible?.
我正在尝试创建一个 PHP 文件来对数据库进行查询,并在提交表单后使用 ajax 调用该文件。
这是个好主意吗?
你是这个意思吗:
add_filter( 'wpcf7_validate', 'email_already_in_db', 10, 2 );
function email_already_in_db ( $result, $tags ) {
// retrieve the posted email
$form = WPCF7_Submission::get_instance();
$email = $form->get_posted_data('your-email');
// if already in database, invalidate
if( email_exists( $email ) ) // email_exists is a WP function
$result->invalidate('your-email', 'Your email exists in our database');
// return the filtered value
return $result;
}
我有最后一个 WordPress 站点,安装了最后一个联系表 7 和火烈鸟插件。
这是一个简单的表单,有一个电子邮件字段和一个消息字段。
我想查询数据库以检查电子邮件是否已经将之前的消息发送到我的站点。
Is this possible?.
我正在尝试创建一个 PHP 文件来对数据库进行查询,并在提交表单后使用 ajax 调用该文件。
这是个好主意吗?
你是这个意思吗:
add_filter( 'wpcf7_validate', 'email_already_in_db', 10, 2 );
function email_already_in_db ( $result, $tags ) {
// retrieve the posted email
$form = WPCF7_Submission::get_instance();
$email = $form->get_posted_data('your-email');
// if already in database, invalidate
if( email_exists( $email ) ) // email_exists is a WP function
$result->invalidate('your-email', 'Your email exists in our database');
// return the filtered value
return $result;
}