eventsmanager

ticket cut-off dates for recurring events

Sep 30th, 2013
299
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. This snippet will make tickets named 'Early Bird' unavailalble 10 days before an event.
  4. Could be useful for creating recurring events, as cut-off dates won't work in these cases.
  5. */
  6. function my_em_ticket_is_available($result, $EM_Ticket){
  7.  
  8.     $date_today = date('Y-m-d');
  9.     $event_start_date = $EM_Ticket->get_event()->event_start_date;
  10.     $nodays = date_diff($date_today,$event_start_date);
  11.  
  12.     if ( $EM_Ticket->ticket_name == 'Early Bird' && $nodays < 10 ) {
  13.         return false;
  14.     }
  15.  
  16.     return $result;
  17. }
  18. add_filter('em_ticket_is_available','my_em_ticket_is_available',10,2);
  19.  
  20. function date_diff($date1, $date2) {
  21.     $current = $date1;
  22.     $datetime2 = date_create($date2);
  23.     $count = 0;
  24.     while(date_create($current) < $datetime2){
  25.         $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
  26.         $count++;
  27.     }
  28.     return $count;
  29. }
  30. ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×