Hi,
Thanks for your reply. did you do this on your site? on that doc, they giving like this
if ( Flamingo_Contact::find( array( 's' => '[email protected]' ) ) ) {
// email exists
}
where should I use this and also how we can assign the dynamic value in array?
i will attach one code that I have tried.
/*We created the filter*/
add_filter( 'wpcf7_validate', 'email_already_in_db', 10, 2 );
/*We created the function*/
function email_already_in_db ( $result, $tags ) {
// We take the information from the form being submitted
$form = WPCF7_Submission::get_instance(); /*Here is the form ID of the Contact Form*/
$email = $form->get_posted_data('Email-sub'); /*Here is the email field*/
// date_default_timezone_set('America/Sao_Paulo'); /*We set the time zone*/
// $datetoday = date("Y-m-d"); /*We take the current date in the format that the contact plugin records the date*/
global $wpdb;
/*We make a select in the table where the contacts are recorded, checking if the email informed already exists on today's date */
$entry = $wpdb->get_results( "SELECT * FROM wp_cf7_vdata_entry WHERE value LIKE '%$email%'" );
// var_dump($entry);
// exit();
// If the select query in the database is positive (the email exists on the current date), it returns the error in the form, in the email field, not sending
if (!empty($entry)) {
$result->invalidate('email', 'Email already exists');
}
return $result;
}