Support

Home Forums Event Espresso Premium [EE4] How to get list of events user sign up for

[EE4] How to get list of events user sign up for

Posted: February 27, 2015 at 3:13 am


Jon Ang

February 27, 2015 at 3:13 am

Hello,

I know the WP User Integration is still being done – but I need to have an ‘See all events I’ve signed up for’ kinda page. It is not unsimilar to having a page on a E-Commerce website to See all MY orders.

Since I have to do this, I’m thinking I’ll just contribute the code to you guys later on for WP User Integration

I only want to list all events that the user has signed up for – and then put a little icon for the user to click to link to the payment page if they have not paid.

Can I receive some directions from a developer on which files/functions I should look at?

I looked at EE_Transaction class and it didn’t seem to be quite what I was looking for.


Lorenzo Orlando Caum

  • Support Staff

March 2, 2015 at 3:19 pm

Hi, please take a look at the last comment in issue 3 on GitHub:

https://github.com/eventespresso/eea-wpuser-integration/issues/3#issuecomment-76706179


Lorenzo


Jon Ang

March 4, 2015 at 8:00 pm

Dear Lorenzo,

Thank you for the answer.

However, while I have access to the main EventEspresso github project, I do not have access to the WP User Integration one.

Can you please assist to grant access on that?

Thank you.


Dean

March 5, 2015 at 4:13 am

I won’t add the full conversation, but here is the pertinent bit:

Hmm..ok, so I tried to start rewriting the function for the recipient edit registration link but its more complex than I thought it would be. To get me started is there a way to pull the registrations for a particular user ID?

Sure! Keep in mind that the data relationships are setup so that one contact may be related to many registrations, and one user is related to one contact.

With that said, the attendee ID is saved on wp_user_meta via the EE_Attendee_ID key. So you can get all the registrations attached to your known user id by doing something like this:

$user_id = get_current_user_id();
$att_id = get_user_meta( $user_id, 'EE_Attendee_ID', true );

//get the attached contact (EE_Attendee)
$contact = EEM_Attendee::instance()->get_one_by_ID( $att_id );

//now we can use that to get all the related registrations (an array of EE_Registrations objects)
$registrations = $contact->get_registrations();

//now you can loop through those EE_Registrations and setup the data you need.
foreach( $registrations as $registration ) {
    echo $registration->event()->name();

    //link to edit attendee information
    echo '<a href="' . $registration->edit_attendee_information_url() . '">Edit your registration details</a>';
}

If I understand the developer right, this would be used in a custom function or custom shortcode or similar.


Jon Ang

March 9, 2015 at 5:46 am

Hello Dean,

I whipped up a quick function.

function wingz_get_my_ee_events_list(){
    $user_id = get_current_user_id();
    $att_id = get_user_meta( $user_id, 'EE_Attendee_ID', true );

    //get the attached contact (EE_Attendee)
    $contact = EEM_Attendee::instance()->get_one_by_ID( $att_id );

    //now we can use that to get all the related registrations (an array of EE_Registrations objects)

    $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 = '<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 .= '</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>';
                if ( $transaction->is_incomplete() ):
                    $payment_action .= '<a href="' . $transaction->payment_overview_url() . '" class="button">' . __( 'Make Payment', 'event_espresso' ) . '</a>';
                endif;
                $html .= '<td class="my-event-actions">' . $payment_action . '</td>';
                $html .= '</tr>';
            endif;
        endforeach;
        $html .= '</tbody>';
        $html .= '</table>';
    else:
        $html = __( 'No Booking Found', 'event_espresso' );
    endif;

    return $html;
}

Pasting it here so that it might benefit someone

But just wondering, Dean, do you forsee an issue if I do not tie it to contact card, my entire basis is on the Attendee ID


Dean

March 10, 2015 at 3:25 am

Hi,

That’s awesome! Thanks for sharing!

The issue I see with using $att_id over $contact in $registrations = EEM_Registration::instance()->get_all_registrations_for_attendee( $att_id);

is it might not catch events where the attendee was not the one logged and and doing the registering but was merely one of the additional attendees.


Jon Ang

March 10, 2015 at 3:46 am

Hello Dean,

Thanks for the reply.

The thing is,


$registrations = $contact->get_registrations();

$contact is still a EEM_Attendee object, and not a EE_Attendee one. $contact->get_registrations() simply fails to compute since those are different classes.

Is there something I am missing here?

By the way, am I correct to say that Contact Cards are governed by attendee ID? Does the WP User Registration plugin right now not log additional attendees into the correct contact card or to the correct attendee ID?


Dean

March 13, 2015 at 5:21 am

I meant:

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

Now I’ll be honest and say that I’m not 100% sure it will matter, but it seems to work fine with the above.

The support post ‘[EE4] How to get list of events user sign up for’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Dean 4 years, 5 months ago ago

Topic Tags

Tagged: 

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!