Title: function em_validate
Last modified: August 30, 2016

---

# function em_validate

 *  Resolved [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/)
 * I am very close the the solution and i need some help. I need make a check of
   em_tickets and if its above one, i need to check the booking_comments are filled
   out .. can someone give me any suggestions ?
 *     ```
       function em_validate($result, $EM_Event){
           if ($_REQUEST['em_tickets'] > 1 && $_REQUEST['booking_comment'] == ''){
         $EM_Event->add_error('Fill out the comments');
           $result = false;
   
        }
        return $result;
       }
       add_filter('em_booking_validate','em_validate', 1, 2);
       ```
   
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794651)
 * you can try this line `$EM_Event->get_bookings()->get_booked_spaces() > 0`
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794710)
 * something like this is also not working
 *     ```
       function em_validate($result, $EM_Event){
       $EM_Ticket_Booking->booking = $this;
         if ($this->get_bookings()->get_booked_spaces() > 1 && $_REQUEST['booking_comment'] == ''){
         $EM_Event->add_error('Fill out the comments');
         $result = false;
        }
        return $result;
       }
       add_filter('em_booking_validate','em_validate', 1, 2);
       ```
   
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794727)
 * What result / output are you getting?
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794729)
 * the validation is not trigging.. its not working
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794736)
 * Which booking mode are you using?
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794737)
 * what is the booking mode?
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794744)
 * that is under Events > Settings > Bookings > No-user booking mode
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794745)
 * Enable No-User Booking Mode? Yes
    Allow bookings with registered emails? Yes
 * I am able to check if the comment box is empty, however i am not able to check#
   of tickets/seats booked. i need to performe a check on this.
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794746)
 * looking in your snippet above
 * it should be
 * `$EM_Event->get_bookings()->get_booked_spaces() > 1`
 * instead of
 * `$this->get_bookings()->get_booked_spaces() > 1`

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘function em_validate’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/function-em_validate/#post-6794746)
 * Status: resolved