Created
April 14, 2018 13:21
-
-
Save campusboy87/4e9272a7280de28ff553035f6cc17f08 to your computer and use it in GitHub Desktop.
Contact Form 7 validate 2 fileds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'wpcf7_validate', 'wpq_validate' ); | |
| function wpq_validate( $result ) { | |
| $form = WPCF7_Submission::get_instance(); | |
| $phone = $form->get_posted_data('phone'); // Имя поля с телефоном | |
| $email = $form->get_posted_data('email'); // Имя поля с email | |
| $error_msg = 'Заполните телефон или email'; | |
| if( empty($phone) && empty( $email ) ) { | |
| $result->invalidate('phone', $error_msg ); | |
| $result->invalidate('email', $error_msg ); | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment