Title: [bugfix] skip_validation_for_hidden_fields issue
Last modified: April 5, 2021

---

# [bugfix] skip_validation_for_hidden_fields issue

 *  Resolved [dedotombo](https://wordpress.org/support/users/dedotombo/)
 * (@dedotombo)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/)
 * Hi,
 * I have been experiencing an incompatibility between this plugin and the WP GDPR
   Compliance plugin: when CF7 conditional fields were enabled, the GDPR field stopped
   validating. Instead of being mandatory, users could proceed without accepting
   the checkbox.
 * After debugging with error_log I found out that the skip_validation_for_hidden_fields
   has a bug, it calls the invalidate method of the WPCF7_Validation object in a
   wrong way.
 * Here is my proposed fix, it seems to work. Instead of passing a string as the
   first argument of the invalidate method, I pass the corresponding WPCF7_FormTag
   object.
 *     ```
       function skip_validation_for_hidden_fields($result, $tags, $args = []) {
   
               if(isset($_POST)) {
                   $this->set_hidden_fields_arrays($_POST);
               }
   
               $invalid_fields = $result->get_invalid_fields();
               $return_result = new WPCF7_Validation();
   
   
               if (count($this->hidden_fields) == 0 || !is_array($invalid_fields) || count($invalid_fields) == 0) {
                   $return_result = $result;
               } else {
                   foreach ($invalid_fields as $invalid_field_key => $invalid_field_data) {
                       if (!in_array($invalid_field_key, $this->hidden_fields)) {
                           // the invalid field is not a hidden field, so we'll add it to the final validation result
       					foreach ($tags as $tag) {
       						if ($tag->name == $invalid_field_key) {
       							$return_result->invalidate($tag, $invalid_field_data['reason']);
       						}
       					}
                       }
                   }
               }
   
               return apply_filters('wpcf7cf_validate', $return_result, $tags);
   
           }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/#post-14283184)
 * Hi dedotombo, thanks for reporting! I checked, and your proposed change seems
   to logically boil down to more or less the same thing. The invalidate function
   will try and parse a string to a $tag anyway, so I went ahead and implemented
   this change because it seems to make sense and all my automated tests still pass.
 * Will release version 2.0.2 with the change shortly.
 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/#post-14288867)
 * should be fixed
 *  Thread Starter [dedotombo](https://wordpress.org/support/users/dedotombo/)
 * (@dedotombo)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/#post-14289079)
 * Thank you Jules, much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[bugfix] skip_validation_for_hidden_fields issue’ is closed to new replies.

 * ![](https://ps.w.org/cf7-conditional-fields/assets/icon-256x256.png?rev=2072595)
 * [Conditional Fields for Contact Form 7](https://wordpress.org/plugins/cf7-conditional-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-conditional-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-conditional-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-conditional-fields/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [dedotombo](https://wordpress.org/support/users/dedotombo/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/#post-14289079)
 * Status: resolved