Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active December 27, 2015 15:29
Show Gist options
  • Select an option

  • Save joshfeck/7348467 to your computer and use it in GitHub Desktop.

Select an option

Save joshfeck/7348467 to your computer and use it in GitHub Desktop.
Add a waitlist event post link to an event custom post type. Requires Event Espresso 3.x. Add to single-espresso_event.php
<?php
// get the waitlist event data for this event
$cpt_event = $wpdb->get_row("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");
$event_attendees_max = $cpt_event->reg_limit;
$num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees
$allow_overflow = $cpt_event->allow_overflow;
$overflow_event_id = $cpt_event->overflow_event_id;
// get the overflow event's post ID
$waitlist_post = $wpdb->get_var("SELECT post_id FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $overflow_event_id . "'");
// check for a full event and for a waitlist event
if (($num_attendees >= $event_attendees_max) && $allow_overflow == 'Y' && $overflow_event_id != 0) {
// build the link to the waitlist event's post ?>
<p><a href="<?php echo post_permalink($waitlist_post); ?>">Join Waiting List</a></p>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment