• Resolved cocacooler

    (@cocacooler)


    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/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try this line $EM_Event->get_bookings()->get_booked_spaces() > 0

    Thread Starter cocacooler

    (@cocacooler)

    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);

    What result / output are you getting?

    Thread Starter cocacooler

    (@cocacooler)

    the validation is not trigging.. its not working

    Which booking mode are you using?

    Thread Starter cocacooler

    (@cocacooler)

    what is the booking mode?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    that is under Events > Settings > Bookings > No-user booking mode

    Thread Starter cocacooler

    (@cocacooler)

    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

    (@angelo_nwl)

    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.