Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created November 23, 2015 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/4817ecea1b6d93da665f to your computer and use it in GitHub Desktop.
Save Pebblo/4817ecea1b6d93da665f to your computer and use it in GitHub Desktop.
An example of how to pull in the latest approved registration details across all events.
<?php
function latest_reg_details() {
$query_params = array(
array(
'STS_ID' => EEM_Registration::status_id_approved
),
'limit' => 1,
'order' => 'DESC'
);
$regs = EEM_Registration::instance()->get_all( $query_params );
$registration = reset($regs);
if ( $registration instanceof EE_Registration ) {
$attendee = $registration->attendee();
if ( $attendee instanceof EE_Attendee ) {
/* Here you have access to the EE_Attendee object for the latest 'Approved' registration */
// Kint debug
// d($attendee);
//Get the full name of the attendee.
$name = $attendee->full_name();
//Get the event from the registration.
$event = $registration->event();
//d($event);
return $output = 'Join ' . $name . ', who registered onto ' . $event->name();
}
}
}
add_shortcode('LATEST_REGISTRATION_DETAILS','latest_reg_details');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment