Advertisement
Guest User

List recurrence dates

a guest
Mar 8th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. //If defined elsewere remove this. I usually place this at the top of the themes functions.php file.
  2. if (!defined('HOME_URL'))
  3. {
  4. define('HOME_URL', home_url());
  5. }
  6.  
  7. //This function grabs dates for related recurrent events and lists their dates and a link to their registration pages
  8. //only if the event is_active and the event_status = A if for some reason you want all events set $only_active to false.
  9. function list_recurrent_event_dates($recurrent_id, $only_active = true) {
  10. global $wpdb;
  11.  
  12. //Grab only the ID and start_date for all recurring events related to the event you're running this function in
  13. $SQL = "select id, start_date from " . EVENTS_DETAIL_TABLE . " where recurrence_id = $recurrent_id";
  14. if($only_active)
  15. {
  16. $SQL .= " AND is_active = 'Y' AND event_status = 'A'";
  17. }
  18. $recurrent_dates = $wpdb->get_results( $wpdb->prepare( $SQL, $event_id ));
  19. //List each recurrent event date and a link to that event if active and registration is open.
  20. foreach ( $recurrent_dates as $recurrence ) {
  21. $is_active = event_espresso_get_is_active($recurrence->id);
  22. if($is_active['status'] == 'REGISTRATION_OPEN')
  23. {
  24. $newStartDate = $recurrence->start_date;
  25. $newStartDate = explode("-", $newStartDate);
  26. $newStartDate = date("F j, Y", mktime(0,0,0,$newStartDate[1],$newStartDate[2],$newStartDate[0]));
  27.  
  28. echo '<a href="' . HOME_URL . '/event-registration/?ee=' . $recurrence->id . '">' . $newStartDate . '</a>, ';
  29. }
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement