wordpress plugin - Validate a text field in contact form 7 and its not working -


here code , not working

add_filter( 'wpcf7_validate_text', 'custom_text_validation_filter', 10, 2 );  function custom_text_validation_filter( $result, $tag ) { $tag = new wpcf7_shortcode( $tag );      if ('couponcode' == $tag->name) { $the_value = $_post[$name];         if($the_value!="abc")         { $result->invalidate( $tag, "invalid coupon code" );         }     }      return $result; } 

any suggestion please ...help me through it

considering using latest version of plugin: give try following...

<?php   add_filter('wpcf7_validate_text', 'your_validation_filter_func', 999, 2);  add_filter('wpcf7_validate_text*', 'your_validation_filter_func', 999, 2);  function your_validation_filter_func($result, $tag) {     $type = $tag['type'];     $name = $tag['name'];     if ('coupon_code' == $name) {     $the_value = $_post[$name];     if($the_value != "abc"){      $result->invalidate($tag, wpcf7_get_message('invalid_coupon_code'));      }    }   return $result; }  add_filter('wpcf7_messages', 'customwpcf7_text_messages');  function customwpcf7_text_messages($messages) {     return array_merge($messages, array( 'invalid_coupon_code' => array(      'description' => __("coupon invalid", 'contact-form-7'),      'default' => __('coupon seems invalid.', 'contact-form-7')   )));   } ?> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -