fbpx
Did you miss our exclusive webinar on Attendee information? Click here to view the recorded session.
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:

  1. Open your child theme’s function.php file.
  2. 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;
        }
    
  3. Save changes.
Validate Submit Event Field Snippets
Ashok Dudhat

Our team constantly explores ways that technology can help us reinvent industries. We want to change the world by creating great products that transform industries. We Dream It, We Make It.

Quick Links
Close
Close