Support

Home Forums Event Espresso Premium Create user account on Import (2)

Create user account on Import (2)

Posted: June 26, 2020 at 3:24 pm


Somatic Practice

June 26, 2020 at 3:24 pm

Hi,

We’re starting to import users into events on our staging site, but there isn’t an account being created in WordPress for them when we import. Is there a way to make this happen? We’re importing the data from a non-wordpress system. Their information includes a name and email address.

Please let me know. Thanks!


Tony

  • Support Staff

June 29, 2020 at 3:07 pm

Hi there,

I checked into this and currently, it isn’t possible without changes within the importer.

EE doesn’t ‘manage’ users currently so with the exception of the WP User Integration add-on creating a user account from the registrations on the front end we don’t do much with WP User accounts at all.

If you are comfortable with PHP you could add a temporary hook into the importer and then use similar code to what the WP User integration add-on has to create a user for each import.

How comfortable with PHP are you?


Somatic Practice

June 30, 2020 at 2:07 pm

I am comfortable enough with PHP to write something; if you can point me in the right direction to get started, that would be much appreciated. I’m assuming this may have something to do with it:

https://gist.github.com/joshfeck/2165ff295c968f861cef8775fc8b1dc9

It’s odd to me that the User Integration doesn’t include creating a user for each registration added via the importer; does EE assume that EE Contacts aren’t needing any way to control their registrations? Or is there a part I’m missing where EE Contacts would be able to login and view their registrations without needing a WP User account?


Tony

  • Support Staff

July 1, 2020 at 5:16 am

I’m assuming this may have something to do with it:

https://gist.github.com/joshfeck/2165ff295c968f861cef8775fc8b1dc9

Sort of, that gist shows you how to find the EE_Contact ID and then assign it to an already existing user. What you need to do is create a WP_User from the details used to create an EE_Contact and then {prefix}EE_Attendee_ID user meta value to it.

Most of the code needed for this is already done for you in the WP User integration add-on, but it only runs on front end registrations and needs tweaking as it’s expecting to run for the currently logged in user.

In the end, it was quicker to provide an example than step through this further so take a look here:

https://gist.github.com/Pebblo/31af4a4c4b291c0a60191a5e7edad6bb

Add the hook I provided into the add-on following the instructions in the gist, then add the snippet in that gist to a custom functions plugin on the site:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Note I highly recommend you create a database backup before using the above just to be safe. The snippet checks for existing users based on the email address and links them to the EE_Contact, if a WP_User isn’t found it creates a new one and updates accordingly.

It’s odd to me that the User Integration doesn’t include creating a user for each registration added via the importer; does EE assume that EE Contacts aren’t needing any way to control their registrations?

No, the importer was designed to allow you to import registrations into EE and not create/manage users. If you already had WP_Users that have been assigned to their relevant EE_Contact (for example if they have previously registered via the front end) then imported registrations would automatically link to the EE_Contact and therefore show up in the My Events section (which I assume you are using) as the EE_Contact would be linked to the user.

I’ll create a ticket to discuss this further internally as I do think having the ability to create users from within the importer can help some users such as yourself. Right now we don’t have any hooks available within the importer that would allow for this but could easily add one/some (although it may not be the same hook I added in the above).


Somatic Practice

July 1, 2020 at 1:57 pm

Thank you for in-depth response- everything worked as you mentioned!

And great to hear that you’ll bring it up internally- it seems like this would be a no-brainer addition to the importer.

The support post ‘Create user account on Import (2)’ 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