Support

Home Forums Community Forum Check ins for user

Check ins for user

Posted: November 7, 2016 at 11:21 am


john-henry

November 7, 2016 at 11:21 am

Hi,

I’ve managed to get a list of registrations for the logged in user from a combination of get_user_meta and the get_all_registrations_for_attendee method.

However, this isn’t exactly what I need. is there a way to get a list of the total check-ins for the user?


john-henry

November 7, 2016 at 1:25 pm

Nevermind, I got this sorted out, just going to comment here in case someone is interested in doing the same:

first off, you need to do the following to get the registrations by user id, just substitute prefix with your database/table prefix:
`$user_id = get_current_user_id();
$att_id = get_user_meta( $user_id, ‘prefix_EE_Attendee_ID’, true );

$registrations = EEM_Registration::instance()->get_all_registrations_for_attendee( $att_id );

//now you can loop through those EE_Registrations and setup the data you need.
if ( $registrations ):
$html = ‘<div class=”my-event-registrations”>’;
$html .= ‘<table class=”event-espresso-my-events”>’;
$html .= ‘<thead>’;
$html .= ‘<tr>’;
$html .= ‘<th class=”my-event-title”><i class=”fa fa-plane”></i>’ . __( ‘Booking’, ‘event_espresso’ ) . ‘</th>’;
$html .= ‘<th class=”my-event-duration”><i class=”fa fa-calendar”></i>’ . __( ‘Duration’, ‘event_espresso’ ) . ‘</th>’;
$html .= ‘<th class=”my-event-status”><i class=”fa fa-star-half-o”></i>’ . __( ‘Status’, ‘event_espresso’ ) . ‘</th>’;
$html .= ‘<th class=”my-event-actions”></th>’;
$html .= ‘<th>’
$html .= ‘</tr>’;
$html .= ‘</thead>’;
$html .= ‘<tbody>’;
foreach( $registrations as $registration ):
if ( $registration instanceof EE_Registration ):
$transaction = $registration->transaction();

$html .= ‘<tr class=”my-event”>’;
$html .= ‘<td class=”my-event-title”>’ . ‘<a href=”‘ . $registration->event()->get_permalink() . ‘”>’ . $registration->event()->name() . ‘</a></td>’;
$html .= ‘<td class=”my-event-duration”>’ . $registration->get_related_primary_datetime()->start_date() . ‘ – ‘ . $registration->get_related_primary_datetime()->end_date() . ‘</td>’;
$html .= ‘<td class=”my-event-status”>’ . $transaction->pretty_status( true ) . ‘</td>’;
$payment_action = ‘<a href=”‘ . $registration->edit_attendee_information_url() . ‘” class=”button”>’ . __( ‘Edit Details’, ‘event_espresso’ ) . ‘</a><br/>’;
if ( $transaction->is_incomplete() ):
$payment_action .= ‘<a href=”‘ . $transaction->payment_overview_url() . ‘” class=”button”>’ . __( ‘Make Payment’, ‘event_espresso’ ) . ‘</a>’;

endif;
$registration_check_in = $registration->check_in_status_for_datetime($this);
if ($registration_check_in == 1):
$registration_check_in = ‘User checked in. Generate certificate’;
endif;
if ($registration_check_in == 2):
$registration_check_in = ‘User didn\’t check in. Don\’t generate certificate’;
endif;
$html .= ‘<td class=”my-event-actions”>’ . $payment_action . ‘</td>’;

$html .= ‘<td class=”my-event-checkin”>’ . $registration_check_in .'</td>’;
$html .= ‘</td>’;
endif;
endforeach;
$html .= ‘</tbody>’;
$html .= ‘</table>’;
$html .= ‘</div>’;
else:
$html = ‘<p>’. __( ‘No Booking Found’, ‘event_espresso’ ). ‘</p>’;
endif;
`

kudos to Jon Ang for providing most of the code for this on this forum topic.

The support post ‘Check ins for user’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso