• I am creating a new form tag, and trying to validate it.

    The validation function is being called, that’s for sure, and the “invalidate” function is called upon the $result object (i.e.: $result->invalidate($tag, ‘…’) ), but it has absolutely no effect!!

    I’m using the same method to validate other fields too, and it works. The only thing is that the other fields are all standard (text, email, file inputs). The custom one does not work!

    For the filter name, I am using the same convention that I’m using for textarea (for example): “wpcf7_validate_textarea”,

    and for my custom tag, I’m using: “wpcf7_validate_my_custom_tag”

    So, what’s going on here?

Viewing 1 replies (of 1 total)
  • Hi, I was actually having the same trouble as you and found your post through a Google search. I actually found the cause of my problem and hope it helps you. I looked at the source code for the invalidate function and I found this:

        
    $name = ! empty( $tag ) ? $tag->name : null;
    
    if ( empty( $name ) || ! wpcf7_is_name( $name ) ) {
        return;
    }
    

    In my case, I didn’t use a name for my custom tag. So as you can see in the code, not having a name causes the function to short-circuit. So you need to pass in a name in the shortcode and you have to set the third parameter of wpcf7_add_shortcode to true (wpcf7_add_form_tag in Contact Form 7 4.6+)

    • This reply was modified 9 years, 1 month ago by kodos84.
    • This reply was modified 9 years, 1 month ago by kodos84.
Viewing 1 replies (of 1 total)

The topic ‘Cannot invalidate custom form tag’ is closed to new replies.