Forum Replies Created

Viewing 1 replies (of 1 total)
  • I have a similar issue, I’m using CFDB plugin and cannot store a unique email field in DB, I’ve tried to add “add shortcode & filters” tool to right this bellow script. but this script is not working for me.
    Please help.

    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”;
    $atts[‘unbuffered’] = ‘true’;
    $exp->export($formName, $atts);
    $found = false;
    while ($row = $exp->nextRow()) {
    $found = true;
    }
    return $found;
    }

    /**
    * @param $result WPCF7_Validation
    * @param $tag array
    * @return WPCF7_Validation
    */
    function my_validate_email($result, $tag) {
    $formName = ‘contact-form-1’; // Change to name of the form containing this field
    $fieldName = ‘your-email’; // Change to your form’s unique field name
    $errorMessage = ‘Email has already been submitted’; // Change to your error message
    $name = $tag[‘name’];
    if ($name == $fieldName) {
    if (is_already_submitted($formName, $fieldName, $_POST[$name])) {
    $result->invalidate($tag, $errorMessage);
    }
    }
    return $result;

    }

    add_filter(‘wpcf7_validate_email*’, ‘my_validate_email’, 10, 2);

Viewing 1 replies (of 1 total)