Support

Home Forums Event Espresso Premium How do I check if a user has paid for the event?

How do I check if a user has paid for the event?

Posted: October 4, 2023 at 4:11 am

Viewing 3 reply threads


jyacolca

October 4, 2023 at 4:11 am

Just following up from previous post:
https://eventespresso.com/topic/how-do-i-check-if-a-user-has-paid-for-the-event/

I would like to know how I can check if the current logged in user has registered for the event. I have access to the event ID.

I’d appreciate your assistance with this.

Thanks,

Johnny


Tony

  • Support Staff

October 4, 2023 at 6:25 am

Hi Johnny,

Firstly, my apologies for missing your reply in the previous thread. I’m not sure how I missed it but obviously have!

An example of checking if the current user has a registration on a specific event can be found here:

https://gist.github.com/Pebblo/10669adfeea322ade3d96a38857fb46b#file-example-php-L10-L29

At that point in the code, you’ll either have an EE_Registration object within $registration or it’ll be null.

You mentioned payment status in your previous thread, but I would actually recommend using the registration status. If a registration has a status of ‘Approved’ it applies to your sold values, which means even if you’ve manually Approved someone without a payment status, they would work with the above setup.

Checking that can be done using:

if( $registration->status_ID() === EEM_Registration::status_id_approved ) {
    // Registration approved, do whatever here!
}

This gets a little more tricky if you are not using the WP User integration add-on but on your reply, I assume you are, correct?


jyacolca

October 6, 2023 at 4:01 am

No worries. Yes, I am using the WP User integration plugin.

Thank you so much! Your solution worked!!
I also agree with your advice of checking registration status instead.

Fantastic, I can now proceed with what I need to do.

Thanks again,

Johnny


Tony

  • Support Staff

October 6, 2023 at 4:08 am

You’re most welcome 🙂

Any further questions/issues just let us know.

Viewing 3 reply threads

The support post ‘How do I check if a user has paid for the event?’ 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