Title: Cannot invalidate custom form tag
Last modified: March 17, 2017

---

# Cannot invalidate custom form tag

 *  [sorincoza](https://wordpress.org/support/users/sorincoza/)
 * (@sorincoza)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/cannot-invalidate-custom-form-tag/)
 * 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)

 *  [kodos84](https://wordpress.org/support/users/kodos84/)
 * (@kodos84)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/cannot-invalidate-custom-form-tag/#post-9017715)
 * 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](https://wordpress.org/support/users/kodos84/).
    -  This reply was modified 9 years, 1 month ago by [kodos84](https://wordpress.org/support/users/kodos84/).

Viewing 1 replies (of 1 total)

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

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [kodos84](https://wordpress.org/support/users/kodos84/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/cannot-invalidate-custom-form-tag/#post-9017715)
 * Status: not resolved