Validate email in Contact form DB
-
Hello.
Previously I used ContactForm7, but decided to move to Fast Secure Contact Form.
Can you please help me with a hook to check if we already have person email in DB (Contact Form DB).
In CF7 I used this one, but don’t know how to update it for FS contact form:
function is_already_submitted($formName, $fieldName, $fieldValue){ require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php'); $exp = new CFDBFormIterator(); $atts = array(); $atts['show'] = $fieldName; $atts['filter'] = "$fieldName=$fieldValue"; $exp->export($formName, $atts); $found = false; while ($row = $exp->nextRow()) { $found = true; } return $found; } function my_validate_email($result, $tag) { $formName = 'FORM_NAME'; // Name of the form containing this field $fieldName = 'WHAT_TO_CHECK'; // Set to your form's unique field name $name = $tag['name']; if($name == $fieldName){ $valueToValidate = $_POST[$name]; if (is_already_submitted($formName, $fieldName, $valueToValidate)) { $result->invalidate($name, 'Please, don't try to register twice.'); // error message } } return $result; } add_filter('wpcf7_validate_email*', 'my_validate_email', 10, 2);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Validate email in Contact form DB’ is closed to new replies.