Created
September 25, 2014 10:18
-
-
Save Pebblo/6d7a223b83cad55b7b22 to your computer and use it in GitHub Desktop.
A functions to build the ticket list by first pulling the attendee's session_id from the DB, then grabbing all the attendee's within that session and looping through them. This is useful for MER registrations..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if there is already one within the file that is still open. | |
function espresso_ticket_links_by_session($registration_id, $attendee_id, $multi_reg, $email = FALSE) { | |
global $wpdb; | |
$sql = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE; | |
if (espresso_is_primary_attendee($attendee_id) != true) { | |
$sql .= " WHERE id = '" . $attendee_id . "' "; | |
} else { | |
$sql .= " WHERE registration_id = '" . $registration_id . "' "; | |
} | |
//echo $sql; | |
$attendee_session = $wpdb->get_var($sql); | |
$sql = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = '" . $attendee_session . "' "; | |
$attendees = $wpdb->get_results($sql); | |
$ticket_link = ''; | |
if ($wpdb->num_rows > 0) { | |
$break = '<br />'; | |
$group = $wpdb->num_rows > 1 ? sprintf(__('Tickets Purchased (%s):', 'event_espresso'), $wpdb->num_rows).$break : __('Download/Print Ticket:', 'event_espresso').$break; | |
foreach ($attendees as $attendee) { | |
$ticket_url = get_option('siteurl') . "/?download_ticket=true&id=" . $attendee->id . "&r_id=" . $attendee->registration_id; | |
if (function_exists('espresso_ticket_launch')) { | |
$ticket_url = espresso_ticket_url($attendee->id, $attendee->registration_id); | |
} | |
$ticket_link .= '<a href="' . $ticket_url . '" target="_blank">' . $attendee->fname . ' ' . $attendee->lname . '</a>' . $break; | |
} | |
if ($email == TRUE){ | |
$text = '<p>' . $group . $ticket_link .'</p>'; | |
}else{ | |
$text = $ticket_link; | |
} | |
return $text; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment