Reputation: 124
Can't seem to use add_filter for Contact Form 7. Ultimately, I'm trying to use the code here to add custom validations: http://code-tricks.com/contact-form-7-custom-validation-in-wordpress/
But the add_filter calls don't seem to hook in where they are supposed to and nothing happens. Doing a simple ECHO test, I can see that the file is loading but no validation occurs.
Any idea what might cause this?
add_filter('wpcf7_validate_text','cf7_custom_form_validation', 10, 2); // text field
add_filter('wpcf7_validate_text*', 'cf7_custom_form_validation', 10, 2); // Req. text field
any specified cf7_custom_form_validation() function simply does nothing when form submitted. Even if I just have it echo some text or manipulate a variable. Nothing happens. The function doesnt' seem to get called.
Upvotes: 1
Views: 4865
Reputation: 1553
FYI, the instructions on the following page are currently wrong - https://contactform7.com/2015/03/28/custom-validation/
The following code $tag->name
needs to read $tag[name]
, since apparently $tag is an array now...
Upvotes: 0
Reputation: 124
Turns out the CF7 core code has been updated and some modifications are necessary to make custom validation work: More details can be found here: http://contactform7.com/2015/01/27/contact-form-7-41/ and here: http://contactform7.com/2015/01/06/contact-form-7
I'll give these a try and mark this as answered if it all works out.
Upvotes: 2
Reputation: 529
I dont think there is the problem with add_filter in your case.This might be because the incorrect id used for validation. Check the form id in the validation code whether it is correctly used or not.
Upvotes: 0