I have the last WordPress site, with the last contact form 7 and flamingo plugins installed.
It's a simple form, with an email field and a message field.
I want to make a query to the database to check if the email had already sent a previous message into my site.
Is this possible?.
I'm trying to create a PHP file that makes the query into the database, and I call that file with ajax after the form is submitted.
Is it a good idea?
Do you mean this:
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;
}