【问题标题】:Validate Contact Form 7 to email address in Participant Database field验证联系表 7 到参与者数据库字段中的电子邮件地址
【发布时间】:2019-01-24 01:03:30
【问题描述】:

我们正在使用联系表 7 和参与者数据库插件。我们希望限制谁能够向 wp_participants_database 表中的电子邮件地址提交“仅限成员”联系表格。

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

谢谢!

【问题讨论】:

    标签: contact-form-7 filter-validate-email


    【解决方案1】:

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

    /***  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;     
    }
    

    【讨论】:

      猜你喜欢
      • 2015-10-06
      • 1970-01-01
      • 2016-08-12
      • 2017-12-10
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-11-15
      • 1970-01-01
      相关资源
      最近更新 更多