• Resolved D_Hahn

    (@d_hahn)


    We have more than two-hundred sites, each with a CF7 form. Adding a reCAPTCHA helped cut down on spam by a lot. We still get bots that can get through, but they don’t appear to be selling or linking to anything and I’ve noticed a strange pattern consistent to them all. In the comments/textarea field, there is a 11-digit number. That’s it. The numbers are random, but they all start with 8 (ex. 89472543261). Anyone else come across this? Can a filter be added using regex in functions.php to reject this pattern?

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi @granerovideo

    I believe you are looking for this! ??
    https://contactform7.com/2020/07/18/custom-spam-filtering/

    Based on my personal experience it won’t help too much (in your case) because that bot learn from failed forms submission (or bot code is fixed manually, don’t know).

    Thread Starter D_Hahn

    (@d_hahn)

    Solved with textarea ‘tellus’

    function custom_textarea_validation_filter($result, $tag) {  
    $type = $tag['type'];
    $name = $tag['name'];
    if($name == 'tellus') {
    $value = $_POST[$name];
    $Match_all = "/^8(\d{10})/";
    if(preg_match($Match_all,$value)){
    
        $result->invalidate( $tag, "11-digit numbers are not allowed !" );
                    }
    }
    return $result;
    }
    add_filter('wpcf7_validate_textarea','custom_textarea_validation_filter', 10, 2);
    add_filter('wpcf7_validate_textarea*', 'custom_textarea_validation_filter', 10, 2);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom validation regex for textarea to prevent bots’ is closed to new replies.