Custom validation filter stucks form validation
-
Hi! I’m trying to implement a custom validation filter to customize the validation error message for “checkbox*” fields named “user-plan”. There’s only one condition to check, whether the field has been filled or not.
The WP/PHP debugging gives no error, and the syntax is checked as correct, but once you try to send the e-mail, the validation and submitting process get stucked and the loader gif spins infinitely.
Here’s the code:
add_filter( 'wpcf7_validate_checkbox*', 'user_plan_validation_filter', 10, 2 ); function user_plan_validation_filter( $result, $tag ) { $tag = new WPCF7_Shortcode( $tag ); if ( $tag['name'] == 'user-plan' ) { $user_plan = $_POST['user-plan']; // $user_plan = isset( $_POST['user-plan'] ) ? trim( $_POST['user-plan'] ) : ''; if ( $user_plan == '' ) { $result->invalidate( $tag, "Selecciona un plan para poder finalizar el tramite" ); } } return $result; }
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Custom validation filter stucks form validation’ is closed to new replies.