Created
May 10, 2017 16:29
-
-
Save joshfeck/1c2dcbd044e0922e1a3add7d45643b21 to your computer and use it in GitHub Desktop.
Support token for Philip https://eventespresso.com/topic/fetch-position-of-ticket-in-espresso_my_events/#post-241033
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 | |
if (is_user_logged_in()) | |
{ | |
global $wpdb, $post; | |
// get current user's User ID & ATT_ID | |
$user_id = get_current_user_id(); | |
$att_id = get_user_option( 'EE_Attendee_ID', get_current_user_id() ); | |
$att_id = (int)$att_id; | |
$reg_count = ''; | |
// get event object from current event post object | |
$event_obj = $post->EE_Event; | |
if ( $event_obj instanceof EE_Event ) | |
{ | |
$regs_count = EEM_Event::instance()->get_all_related( | |
$event_obj, | |
'Registration', | |
array( | |
array( | |
'STS_ID' => array( | |
'NOT_IN', | |
array( | |
EEM_Registration::status_id_cancelled | |
) | |
) | |
) | |
) | |
); | |
} | |
if ( $regs_count && isset($att_id) ) | |
{ | |
$user_position = ''; | |
$i = 1; | |
foreach ($regs_count as $reg) | |
{ | |
if ($reg->attendee_ID() === $att_id) | |
{ | |
$user_position = $i; | |
break; | |
} | |
$i++; | |
} | |
echo "<p>positions for user Id: ". $user_id .'</p>'; | |
if ( $user_position ) | |
{ | |
echo '<p>Position for event is '. $user_position .'</p>'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment