Posted: November 20, 2017 at 1:01 pm
I’m using the WP Users plugin, and all new event registrations create a new WP user. When they login, they are taken to their Dashboard where I show them custom content. What I need to do is to be able to show them some Event Espresso content, too. I am using the event/page ID to pull some Advanced Custom Fields data for that user, specifically a file download link. But what I need to do is find all the event/page IDs for that one user while they are in their Dashboard. I display the download link like this
i.e., for the event/page ID 132. That works now; but of course, the event/page ID needs to be dynamic for each user. How can I get all event IDs for a user in their Dashboard? I need to loop through them in case there are more than one and then use
with each $post_id being the event ID. I’m looking at eea-wp-users-registrations-table.template.php, since that is used to display registrations on the Profile. But I can’t see how to copy and modify parts of that to get all event IDs by user, rather than registrations, in the Dashboard, and I get “Undefined variable: registrations” errors. Thanks |
|
I fond this after I posted my question: https://eventespresso.com/topic/ee4-how-to-get-list-of-events-user-sign-up-for/ The code snippet by Jon Ang is a good starting point for me. I tested the |
|
So $att_id is null?
No. Have you completed a registration using the user account you are using above? It’s pulling the current user_id and then checking if it has an EE_Attendee_ID assigned to it, so if you haven’t completed a registration on that user account using details that match the user account you won’t have that value. This is how I would pull an array of Event IDs that a user has registrations for:
|
|
Ah, thanks! Starting to make sense. I did have one registration, but it wasn’t showing up with my first code snip. With your function, it did in var_dump, as With one registration, |
|
You need to loop through the array of event ID’s and pull the meta field for each, something like:
|
|
Thanks! THis works:
Problem now is that while the registration list in the profile shows canceled registrations, my loop shows downloads. So I need to only show users who are approved for event(s). Is there a variable for that? |
|
Have you thought about using the my events section of the WP user add-on? There’s a front-end facing version and one within the admin, look at the users profile and you’ll find it there. As for pulling only Approved registrations you can use:
In place of the original call to just pull all registrations. |
|
I did look in those files but couldn’t figure it out. Replacing |
|
Sorry, that does work. My mistake. Thanks! |
|
The support post ‘How can I get all event ID's for a WordPres user in the user Dashboard?’ 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.