Title: scripting question
Last modified: August 30, 2016

---

# scripting question

 *  Resolved [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/)
 * I have written the following in my functions.php however i am unable to make 
   it work..only the e-mail feild is getting validated..
 *     ```
       <?php function em_validate($result, $EM_Event){
       if ($_REQUEST['em_tickets'] > 1 && $_REQUEST['booking_comment'] == ''){
       $EM_Event->add_error('fill more names');
       $result = false;
       }
       return $result;
       }
       add_filter('em_event_validate','em_validate', 1, 2);
       ?>
       ```
   
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

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

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788810)
 * hmm, can I know what are the other fields that you’ve wanted to validate?
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788812)
 * i want to validate
 * if em_tickets more than 1
    and there is should be something in booking_comment
 * currrently only email gets validated.
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788832)
 * Have you tried checking for the _strlen_ of $_REQUEST[‘booking_comment’] ?
 * [http://php.net/manual/en/function.strlen.php](http://php.net/manual/en/function.strlen.php)
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788833)
 * please see my above function
 * thats what i am trying to do
 *     ```
       if ($_REQUEST['em_tickets'] > 1 && $_REQUEST['booking_comment'] == ''){
       ```
   
 * but the above function is not trigging at all
 *     ```
       function em_validate($result, $EM_Event){
       if ($_REQUEST['em_tickets'] > 1 && $_REQUEST['booking_comment'] == ''){
       $EM_Event->add_error('fill more names');
       $result = false;
       }
       return $result;
       }
       add_filter('em_event_validate','em_validate', 1, 2);
       ```
   
 *  Thread Starter [cocacooler](https://wordpress.org/support/users/cocacooler/)
 * (@cocacooler)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788855)
 * I have almost created the validating part, however i am not able to get the number
   of tickets reserved.. can someone point out an solution ?
 * this part is not working : $_REQUEST[’em_tickets’] > 1
 * This is my code:
 *     ```
       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);
       ```
   
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/scripting-question/#post-6788926)
 * try to use `$EM_Event->get_bookings()->get_booked_spaces()` instead of `$_REQUEST['
   em_tickets']`
 * eg. under classes/em-bookings.php

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

The topic ‘scripting question’ 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/)

 * 6 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/scripting-question/#post-6788926)
 * Status: resolved