Posted: June 26, 2020 at 3:24 pm
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!
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?
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:
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?
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
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:
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:
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.
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).
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’ 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.