0

我们正在使用 Contact Form 7 和 Participants Database 插件。我们希望限制谁能够向 wp_participants_database 表中的电子邮件地址提交“仅限成员”联系表格。

有没有办法使用该表中的电子邮件字段验证联系表单中的电子邮件地址?

谢谢!

4

1 回答 1

0

在参与者数据库支持的帮助下自己解决了这个问题。通过更改检查数据库的行,它可以用于其他验证。

/***  Contact 7 filter to check Participants Database for member email ***/    

add_filter( 'wpcf7_validate_email*', 'email_in_participants_db', 20, 2 );

function email_in_participants_db( $result, $tag ) {    

// retrieve the posted email
$form  = WPCF7_Submission::get_instance();
$your_email = $form->get_posted_data('member-email');

// if  in database, validate 
// code from PD - Participants_Db::get_record_id_by_term($term, $value);
$member_id = Participants_Db::get_record_id_by_term( 'email', $your_email );

if( ! $member_id ) {
    $result->invalidate('member-email', 'That email address is not in the Member Directory. Please contact the Guild if you need to update it.'); 
    }
// return the filtered value
return $result;     
}
于 2018-08-18T23:05:13.287 回答