Skip to content

Instantly share code, notes, and snippets.

@campusboy87
Created April 14, 2018 13:21
Show Gist options
  • Select an option

  • Save campusboy87/4e9272a7280de28ff553035f6cc17f08 to your computer and use it in GitHub Desktop.

Select an option

Save campusboy87/4e9272a7280de28ff553035f6cc17f08 to your computer and use it in GitHub Desktop.
Contact Form 7 validate 2 fileds
<?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