• Hello,

    When a customer submits an email via contact form 7, how do I check if the email already exists in my database and change the notification message to “Your email already exists in our database”. How we can solve the issue?

    I have tried this code. but not working.

    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;
    }
  • The topic ‘Validate existing email address’ is closed to new replies.