• Resolved lfbender

    (@lfbender)


    I have looked for hours now for proper documentation and forum posts on this(including https://contactform7.com/2015/03/28/custom-validation/#more-13626), and I am coming up empty. The following doesn’t work:

    function spam_handling($result, $tag) {
        // $spam = array('google', 'McDonalds');
    
        // if($tag->name == 'Company'):
            
        //     if(in_array($_POST['Company'], $spam)):
                
                $result->invalidate( $tag, "Spam" );
                
            // endif;
            
            // endif;
        
        return $result;
    }
    
    add_filter("wpcf7_validate_text", "spam_handling", 5, 2);

    What is the correct hook to use to validate text fields or specific fields in contact form 7? I am using the most up to date version. Also WordPress is updated.

    • This topic was modified 4 years, 1 month ago by lfbender.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter lfbender

    (@lfbender)

    The hook works now and I don’t have an explanation as to what changed. Might have been a caching issue.

Viewing 1 replies (of 1 total)
  • The topic ‘Contact Form 7 custom validation hook not working’ is closed to new replies.