• Good Morning

    I have a form where I need to check if the email being entered is already registered on my database (I’m using Flamingo). This works just fine, but I need to change the error that is displayed when a repeated email is found. When this occurs, all i get is a red tooltip with an “X” next to the email field. I need this to be more descriptive or print the error below the field or below the form. My problem is that the message is not being displayed.

    The code I’m using to validate the email is as follows:

    add_filter( ‘wpcf7_validate’, ’email_already_in_db’, 20, 2 );

    function email_already_in_db ( $result, $tags ) {
    // retrieve the posted email
    $form = WPCF7_Submission::get_instance();
    $email = $form->get_posted_data(’email’);
    // if already in database, invalidate
    if( email_already_in_database( $email ) ){
    $result->invalidate(’email’, wpcf7_get_message(‘Your email exists in our database’));
    }
    // return the filtered value
    return $result;
    }

    function email_already_in_database($email){
    global $wpdb;
    $result = $wpdb->get_results(“SELECT meta_key FROM wp_postmeta WHERE meta_key=’_field_email’ and meta_value=’$email'”);
    foreach($result as $row) {
    if($row->meta_key){
    return true;
    }else{
    return false;
    }
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change message that is displayed on error’ is closed to new replies.