Skip to content

Instantly share code, notes, and snippets.

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 joshfeck/1c2dcbd044e0922e1a3add7d45643b21 to your computer and use it in GitHub Desktop.
Save joshfeck/1c2dcbd044e0922e1a3add7d45643b21 to your computer and use it in GitHub Desktop.
<?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