"Unique Field – Prevent Contact form 7 Duplicate Submissions" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Unique Field – Prevent Contact form 7 Duplicate Submissions" answered properly. Developers are finding an appropriate answer about Unique Field – Prevent Contact form 7 Duplicate Submissions related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Unique Field – Prevent Contact form 7 Duplicate Submissions. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Unique Field – Prevent Contact form 7 Duplicate Submissions.
Unique Field – Prevent Contact form 7 Duplicate Submissions
function is_already_submitted($formPostId, $fieldName, $fieldValue) {
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 DB_PREFIX_db7_forms WHERE form_value LIKE '%$fieldValue%' AND form_post_id = '$formPostId'" );
// 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
$found = false;
if (!empty($entry)) {
$found = true;
}
return $found;
}
function my_validate_email($result, $tag) {
$formPostId = 'FORM_ID'; // Change to name of the form containing this field
$fieldName = 'your-email'; // Change to your form's unique field name
$errorMessage = 'This email address is already registered'; // Change to your error message
$name = $tag['name'];
if ($name == $fieldName) {
if (is_already_submitted($formPostId, $fieldName, $_POST[$name])) {
$result->invalidate($tag, $errorMessage);
}
}
return $result;
}
add_filter('wpcf7_validate_email*', 'my_validate_email', 10, 2);
All those coders who are working on the Whatever based application and are stuck on Unique Field – Prevent Contact form 7 Duplicate Submissions can get a collection of related answers to their query. Programmers need to enter their query on Unique Field – Prevent Contact form 7 Duplicate Submissions related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Unique Field – Prevent Contact form 7 Duplicate Submissions for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Unique Field – Prevent Contact form 7 Duplicate Submissions while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Unique Field – Prevent Contact form 7 Duplicate Submissions". Visit this developer's friendly online web community, CodeProZone, and get your queries like Unique Field – Prevent Contact form 7 Duplicate Submissions resolved professionally and stay updated to the latest Whatever updates.