How to validate contact form 7 telephone number in WordPress

As we know that the contact form 7 is the most used plugin in wordpress for creating contact forms and sending emails etc.In wordpress, plugins are developed in such way using the wordpress hooks concept “action and filter” through which someone can easily customize any plugin without modifying core files of plugin.
So, contact form 7 has already added validation on different types of fields in formatting.php file in which validation rules are defined.Here, we need to alter the validation of telephone field which is already applied in below mentioned function and we can override it using filter hook “add_filter” because “apply_filters” is used to return the validation result.

Please add the below mentioned code in functions.php in your activated theme folder and add your validation rule to $result

 

 

 

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *