Support

Home Forums Event Espresso Premium Hook for User Creation

Hook for User Creation

Posted: March 11, 2014 at 5:01 pm


Adam Broetje

March 11, 2014 at 5:01 pm

We have two events, one supporting individual registration and a second that supports group registration.

Upon a registration completing, we are generating a WP user for them and sending a confirmation email. This is where we got the original “User Creation” script from: https://gist.github.com/sethshoultes/5574217

The trouble we’re having is selecting the right hook to tie into.

action_hook_espresso_save_attendee_data
We tried this as it’s the one in the sample, however it was sending emails before the person actually paid.

action_hook_espresso_track_successful_sale
We tried this one, but only the registrant actually paying the fee would have a user generated. Any members who were part of a group registration and weren’t the member making the payment did not have a user generated.

Any other ideas of hooks we should use to make this work? I would love to find a “Confirmed Registration” hook but it doesn’t appear to exist.


Dean

March 12, 2014 at 2:30 am

I haven’t tested it, but what about the _email_after_payment hook?

https://eventespresso.com/wiki/event-espresso-3-1-action-hooks/#action_hook_espresso_email_after_payment

All available hooks in EE3 are found here – https://eventespresso.com/wiki/event-espresso-3-1-action-hooks/


Adam Broetje

March 12, 2014 at 3:42 pm

I’ll give it a shot and report back.


Adam Broetje

March 12, 2014 at 4:19 pm

No dice. Only the main group member who actually made the payment has a user created for them. Any of the additional members do not.

Suggestions on a work around here?


Dean

March 13, 2014 at 1:29 am

Thinking about this again, you said

“action_hook_espresso_save_attendee_data
We tried this as it’s the one in the sample, however it was sending emails before the person actually paid.”

If you are just concerned about registration emails, you could use this hook, but change the General Setting “Send registration confirmation emails before payment is received?” to No. That way no emails would go out until the payment was received.

Other than that I could only suggest a custom function based on one of the other hooks that takes the session ID and searches the events_attendee table for the attendees with that session ID (attendee_session column).


Adam Broetje

March 14, 2014 at 2:57 pm

I looked into it and turns out we have had the “Send registration confirmation emails before payment is received?” set to “No” this entire time and it was still generating the user prior to payment.


Adam Broetje

March 14, 2014 at 3:14 pm

What I’m going to try is using the action_hook_espresso_update_attendee_payment_status hook so that whenever an attendee’s status is changed to “completed”, the user is generated and a welcome email is sent.

My concern is what happens if a user is “confirmed”, we then change their status back to “pending” and to “confirmed” again? Will the password email send a second time or will the user creation fail because the email address is already associated with a user?


Dean

March 17, 2014 at 1:22 am

Hi

“Send registration confirmation emails before payment is received?” set to “No” this entire time and it was still generating the user prior to payment.

This should not occur, unless the user is marked as Completed for any reason.

I would revert to a default copy of the plugin (i.e. no modifications) and see if that still occurs.

My concern is what happens if a user is “confirmed”, we then change their status back to “pending” and to “confirmed” again?

It depends on how you code it. The snippet Seth made was based on the users email, so it would (correctly) fail if that email exists and not create a user. You would need to make sure that there was something in place to do the same.


Adam Broetje

March 18, 2014 at 6:38 pm

We ended up writing a custom plugin that uses two of the hooks and a filter to achieve what we needed.

action_hook_espresso_save_attendee_data
Was used to save the attendee data & create users.

action_hook_espresso_track_successful_sale
Was used to initiate the send of the email if the payment status was not “Payment Declined”

Thanks for your help!


Dean

March 19, 2014 at 5:15 am

Awesome! Glad you got it sorted!

The support post ‘Hook for User Creation’ 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