How can we help?
Validate submit event field Snippets
Validation refers to the process of checking the accuracy of the information provided. When an event is posted on a website, it determines the credibility of the organizer. Hence it becomes of utmost importance to provide the details accurately.
The following steps must be taken to check validation on a particular field while submitting an event form:
- Open your child theme’s function.php file.
- Add the following code:
add_filter('submit_event_form_validate_fields', 'wpem_submit_event_form_validate_fields', 10, 3); function wpem_submit_event_form_validate_fields($string, $fields, $values) { foreach ( $fields as $group_key => $group_fields ) { foreach ( $group_fields as $key => $field ) { if($key == 'phone_no') { if(strlen($values[$group_key][$key]) <= 10) { return new WP_Error( 'validation-error', __( 'Please Enter 10 Digit Number', 'wp-event-manager' ) ); } } } } return $string; }
- Save changes.