Support

Home Forums Event Espresso Premium Creating Multiple Users Upon Registration of an Event

Creating Multiple Users Upon Registration of an Event

Posted: November 9, 2022 at 1:47 pm


Katelyn

November 9, 2022 at 1:47 pm

Based off of this post (https://eventespresso.com/topic/create-users-for-each-of-the-registrants/), I’ve been unsuccessful with the code snippet. I’ve created my own “plugin” and uploaded it to the FTP. Is there something else on my end I need to do?


Tony

  • Support Staff

November 9, 2022 at 2:02 pm

Hi there,

So you follow the steps here:

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

Created a custom functions plugin and uploaded it to your site, added the snippet from the other thread:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_ee_process_multi_wpuser_for_attendees.php

Did you activate the custom functions plugin?


Katelyn

November 9, 2022 at 2:26 pm

This reply has been marked as private.


Tony

  • Support Staff

November 9, 2022 at 2:30 pm

Your running PHP8 and that snippet needs a quick update for it.

Change this line:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_ee_process_multi_wpuser_for_attendees.php#L18

To be:

if (defined('EE_FRONT_AJAX') && EE_FRONT_AJAX) {


Katelyn

November 9, 2022 at 2:34 pm

Thank you kindly! I will keep you posted to see if this works.


Tony

  • Support Staff

November 9, 2022 at 2:45 pm

Just a quick note for future readers of this thread, I’ve updated the snippet with the above change so no need to change it anymore.


Katelyn

November 9, 2022 at 6:25 pm

Thank you, Tony, for your assistance. This worked beautifully. Is there the option to create a username based off of their first and last name? Right now it’s creating the username based upon email address.

In addition to that, is there a code snippet that possibly goes off of that one? I have administrative assistants and personnel signing up multiple people at a time for events and won’t always be able to have certain individuals sign up for themselves. I’d love it if you had the option to say, “If this account exists, please still continue with purchase of said ticket for specified user.”


Tony

  • Support Staff

November 10, 2022 at 12:51 pm

Is there the option to create a username based off of their first and last name? Right now it’s creating the username based upon email address.

Sure, thats now your own custom function so you can change the code how you prefer, this section:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_ee_process_multi_wpuser_for_attendees.php#L67-L76

Is what creates the user account and yes it currently uses $attendee->email(), you can change that out for whatever you want to use there.

In addition to that, is there a code snippet that possibly goes off of that one?

Sorry, I’m not sure I follow. Goes off and does what?

I have administrative assistants and personnel signing up multiple people at a time for events and won’t always be able to have certain individuals sign up for themselves. I’d love it if you had the option to say, “If this account exists, please still continue with purchase of said ticket for specified user.”

By specified user, do the registrant details? I assume you don’t mean the admin.


Katelyn

November 10, 2022 at 1:15 pm

Thank you. I will look further into this.

I have administrative assistants sign-up two users. If one of those users is created through that code snippet, but the administrative assistant wants to sign them up for an additional event… it will prompt that user to sign into their own account. Is there a way around that?


Tony

  • Support Staff

November 10, 2022 at 2:48 pm

Yes, you can disable that check, using the second snippet here:

https://gist.github.com/joshfeck/1131145859a3fab58f4d#file-disable_email_match_everyone-php

Be careful when doing this, the reason that functionality exists is to keep your registration synced with the correct WP user account, disabling it can stop that happening.

I highly recommend disabling the WP User sync feature when using the above snippet:

Event Espresso -> Registration Form -> User integration settings.

Set ‘Always sync contact information with WP user profile?’ to No and save.


Katelyn

November 16, 2022 at 1:29 pm

I still appear to be having an issue with the

if (defined('EE_FRONT_AJAX') && EE_FRONT_AJAX) {

with the plugin. Every now and then, it’ll give me a technical error and then a critical error. Any suggestions?


Tony

  • Support Staff

November 16, 2022 at 1:35 pm

Check the server’s error logs to see what the ‘full error’ being thrown is an post that here.

The above could be from any code running, so we need the ‘ful’ error to troubleshoot.


Katelyn

November 21, 2022 at 6:26 am

This reply has been marked as private.


Tony

  • Support Staff

November 21, 2022 at 8:12 am

Hi,

That looks like an access log rather than the PHP error log?


Katelyn

November 21, 2022 at 12:36 pm

This reply has been marked as private.


Tony

  • Support Staff

November 21, 2022 at 4:02 pm

Within:

/wp-content/plugins/Event Espresso – Create Users Upon Registration/ee_createusers.php

What is line 24?


Katelyn

November 22, 2022 at 6:31 am

I believe it’s this section because it’s saying, “Uncaught Error: Undefined constant “EE_FRONT_AJAX””

if (defined(‘EE_FRONT_AJAX’) && EE_FRONT_AJAX) {
remove_action( ‘AHEE__EE_Single_Page_Checkout__process_attendee_information__end’, array( ‘EED_WP_Users_SPCO’, ‘process_wpuser_for_attendee’ ), 11 );
add_action( ‘AHEE__EE_Single_Page_Checkout__process_attendee_information__end’, ‘jf_ee_process_wpuser_for_attendee’, 10, 2 );
}
}


Tony

  • Support Staff

November 22, 2022 at 9:21 am

The error is stating EE_FRONT_AJAX is undefined, yet the code you’ve included is explicitly checking to see if its defined first:

if (defined('EE_FRONT_AJAX') && EE_FRONT_AJAX) {

This part defined('EE_FRONT_AJAX') says ‘if EE_FRONT_AJAX is defined….’

Then this part && EE_FRONT_AJAX says ‘AND EE_FRONT_AJAX is a truthy value’.

So getting the above error for that code doesn’t really make sense.

Can you post the full contents of that file to Pastebin so I can take a look?


Katelyn

November 22, 2022 at 10:06 am

https://pastebin.com/1kD0vbuS


Tony

  • Support Staff

November 22, 2022 at 10:37 am

Yeah, that makes no sense!

The code is literally checking to see if the constant is defined before using it.

That’s definitely the correct file, right? As in you don’t have multiple custom function plugins and that’s the ‘fixed’ one but the ‘other’ is actually the one activated (I’ve got to ask as I’ve seen it happen before).


Katelyn

November 22, 2022 at 11:15 am

It should be the correct file, although I’ve since renamed the plugin name within the file and it’s still showing up under the old name. Any recommendations would be great on how to ensure it’s the correct file.


Tony

  • Support Staff

November 22, 2022 at 12:53 pm

It should be the correct file, although I’ve since renamed the plugin name within the file and it’s still showing up under the old name.

That doesn’t sound like the right file.

Hover over the deactivate link in Dashboard -> Plugins.

Look at the URL in the browser, it will show you the directory and filename:

https://monosnap.com/file/9BSWeBiBvHZjel41hnuxPQSeBf6oVg

That’s the plugin directory name and the plugin file name.


Katelyn

November 22, 2022 at 1:42 pm

I think we have it sorted now, Tony. My apologies.

Would you be able to tell me if there’s page or a way to create a page that has all of the events a specific user is attending?


Tony

  • Support Staff

November 22, 2022 at 1:59 pm

Something like the My Events section?

https://eventespresso.com/wiki/wp-user-integration/#ee4-my-events

That’s using the [ESPRESSO_MY_EVENTS] shortcode with the WP user integration add-on.


Katelyn

November 22, 2022 at 2:03 pm

That’s perfect! Thank you, Tony.


Tony

  • Support Staff

November 22, 2022 at 2:14 pm

You’re most welcome 🙂


Katelyn

November 25, 2022 at 9:43 am

I have one more question as it pertains to registration. Right now, users receive an email and their brought to the backend of WordPress. Is there, or is it possible to create, a front-end registration form so users don’t see the backend?


Tony

  • Support Staff

November 28, 2022 at 5:00 am

Is this when the user confirms the email within the email send by WordPress?

You could use a plugin such as this:

https://wordpress.org/plugins/remove-dashboard-access-for-non-admins/

TO remove dashboard access for subscribers (which I assume is what you have the above set to create?).


Katelyn

November 28, 2022 at 6:42 pm

Yes; is there a way to integrate the Gravity Forms User Registration Add-On and have the user go through that to set their password? Or is the registration from WordPress set-up through the back-end something that needs to happen?


Tony

  • Support Staff

November 29, 2022 at 2:47 pm

Yes; is there a way to integrate the Gravity Forms User Registration Add-On and have the user go through that to set their password?

Not really, you’re using custom code to automatically generate user accounts from the values passed to it, I’m not sure how you would then use the Gravity From User Registration add-on to work with that?

Or is the registration from WordPress set-up through the back-end something that needs to happen?

The user doesn’t need any access to the dashboard/wp-admin in terms of Event Espresso, or the WP user account. The WP user account is created in the same way WordPress created them and an email sent for them to set the password is what you are getting currently I assume?

Can you include a couple of screenshots showing what is happening? (You can mark you replay private so only EE staff can view them)

https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots


Katelyn

December 5, 2022 at 10:36 am

One more question, sorry.

I current am using WP User Integration, the PHP that allows users to purchase multiple tickets at a time, and the “Always sync contact information with WP user profile? set to ‘No.’

If UserA purchases tickets for UserB, I want UserB to see that ticket on UserB’s profile. Is that something that can happen or not the way I have it set-up currently?


Tony

  • Support Staff

December 5, 2022 at 3:13 pm

Have you tested if that isn’t the case already?

The code above looks like it should already handle that use case.


Katelyn

December 5, 2022 at 6:17 pm

I think I found the missing piece of the puzzle because it was still asking if you had an account to login. But, is this code okay to go in something like a Code Snippet plugin or does it need to be it’s own, standalone, plugin?

`add_filter( ‘EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check’, ‘__return_false’ );


Tony

  • Support Staff

December 6, 2022 at 3:33 am

Do you mean a code snippet plugin that allows you to add snippets from within the admin? If so it depends on when that plugin is running the code.

However, it will be slightly fast to load your custom code into an actual custom plugin so it doesn’t need to be loaded from the database each time. You don’t need every single snippet in its own plugin, but create a custom functions plugin to hold your custom snippets and place them all in there (you can also split them into different individual plugins if needed, that’s up to you.

The code above should run fine anywhere as long as it runs before EE’s code to hook in before it runs.


Katelyn

December 6, 2022 at 6:40 am

I’m currently running WPCode for the code snippets. Last night, I was successful in signing up for a ticket without logging in but the second ticket I purchased was not attached to the user’s account.

I’m going to try to test this morning to see if putting that code in a separate plugin will help.


Tony

  • Support Staff

December 6, 2022 at 9:29 am

If EE is no longer asking for them to log in, then that snippet is running fine.

The code uses the email address to pull in the WP User account.

This part of the code:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_ee_process_multi_wpuser_for_attendees.php#L110-L119

Check if the current WP User already has an EE_Contact ID assigned to it ($att_id), if it’s empty and sync_user_with_contact OR the attendee details match the WP user details, it will sync that EE_Contact ID to the WP User.

If the user already has a contact assigned to them, then the registrant details input must match the first name, last name and email address exactly to link them up.


Katelyn

December 8, 2022 at 7:32 pm

Okay, so if the first name was ‘Ben’ and I input ‘Benjamin,’ that would not allow it to hook up to that attendee? Can I just have the email match or does it need to go off of the first name, last name and email address?


Tony

  • Support Staff

December 9, 2022 at 3:30 am

Okay, so if the first name was ‘Ben’ and I input ‘Benjamin,’ that would not allow it to hook up to that attendee?

No, it needs to match exactly.

Can I just have the email match or does it need to go off of the first name, last name and email address?

No, because users use the same email address for multiple registrations.

For example, someone may register 3 people and chose to use the same email address for them, their partner and their child but all different names.

Now you’re getting into the complexities of creating multiple user accounts from registrations 🙂


Katelyn

December 9, 2022 at 5:03 am

This reply has been marked as private.


Tony

  • Support Staff

December 9, 2022 at 5:20 am

It’s not just with parent and child, that’s a quick example but the short answer is doing this based purely on the email address provided in a registration increases the risk of linking to the wrong user.

If this happens and you end up with multiple records needing to be fixed, it’s on you rather than us to fix it as its removes the safeguarding we are doing on this. I’ll help point you in the direction you want to go here but if I don’t say the above and you return in 6 months with 2000 records needing to be fixed it’s then on me 🙂

Event Espresso itself will use the first name, last name and email address when checking EE_Contacts, your custom function about can skip first name and last name checks when it has created the user account on that request by changing this:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_ee_process_multi_wpuser_for_attendees.php#L114-L116

To just be:

$attendee->email() === $user->user_email

Which I think will do what you are asking for.


Katelyn

December 9, 2022 at 6:29 am

Thank you for your assistance!

In this instance, do you know if there’s an easy way to, as an administrator, switch tickets between users manually — if that were to happen?


Tony

  • Support Staff

December 9, 2022 at 7:42 am

Switch tickets?

Can you expand on what you mean a little more please?


Katelyn

December 9, 2022 at 7:53 am

So, I guess if someone were to purchase a ticket and misspelled the email address, would we have to cancel that transaction and put through another one manually? Or is there a way to configure it to go to the correct person on the back-end in WordPress?


Katelyn

December 9, 2022 at 2:19 pm

I signed up, without logging into the website, and tested purchasing two tickets. One for myself and one for a colleague. It connected one of the tickets to my account just fine; the first entry. The second ticket, for my colleague, was not put into his “My Event Tickets” page.

Is that a known issue with having it set-up this way, as well?


Katelyn

December 9, 2022 at 5:00 pm

The other issue is now the Pending Registrations are still showing up even though I’ve manually marked them as paid in the backend of the system.


Tony

  • Support Staff

December 13, 2022 at 4:42 am

So, I guess if someone were to purchase a ticket and misspelled the email address, would we have to cancel that transaction and put through another one manually? Or is there a way to configure it to go to the correct person on the back-end in WordPress?

It gets a little complicated because now you’ll have a WP User created with the wrong email address and an EE_Contact created with the ‘wrong’ values and also at least 1 registration linked to that wrong contact AND that contact linked to the wrong WP User account.

If the user already has an EE_Contact (the ‘correct’ EE_Contact) then I have a snippet you can use to set the ATT_ID (Contact ID) on a registration which means you can update a registration to switch from one contact to another:

https://gist.github.com/Pebblo/239dcbbab9514c13ba48fe3e8e9a5add

That only works if they already had a contact before making the error so you can swap the registration to the correct one (as long as that contact is then linked to the correct WP user).

I signed up, without logging into the website, and tested purchasing two tickets. One for myself and one for a colleague. It connected one of the tickets to my account just fine; the first entry. The second ticket, for my colleague, was not put into his “My Event Tickets” page.

Did you match the details exactly on second ticket to the other user?

Did that user already have an EE contact? As in has they already made registrations whilst logged in and have those show in the My Events section?

Check the registration and see if its linked to the correct EE_Contact for that user (compare the EE_Contact ID on that registration with one that does show up in my events).


Tony

  • Support Staff

December 13, 2022 at 4:42 am

The other issue is now the Pending Registrations are still showing up even though I’ve manually marked them as paid in the backend of the system.

I don’t follow here, can you explain further? Or include some screenshots?

https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots


Katelyn

December 13, 2022 at 6:26 am

This reply has been marked as private.


Tony

  • Support Staff

December 13, 2022 at 9:08 am

Where would I find the EE_Contact ID for that specific user?

Edit the user account in Dashboard -> Users.

You should see their registrations at the bottom of the profile page and a button that takes you to ‘View Linked Contact’. CLicking on that will take you to the linked contact for that user.

The other issue I’m having, with the pending registrations, you may review the screenshot here:

Your not looking at pending registrations there, your view upcoming events.

Click on the icon and you’ll see a list of registrations related to the event the row is for, do those show as Pending or Approved?


Katelyn

December 13, 2022 at 9:22 am

So, no, only one of those courses is showing linked to that specific user/EE_Contact ID.

If I click the gear, those registrations show up as approved. I was reading it, based on the key, as though the green was “Pending payment.”


Tony

  • Support Staff

December 13, 2022 at 9:33 am

So, no, only one of those courses is showing linked to that specific user/EE_Contact ID.

Right, so use the snippet I posted above in a custom functions plugin:

You can add that to a custom functions plugin on your site, we have some documentation on creating one here:

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

And update the ATT_ID for the ‘broken’ registration to be the correct ID for that user. The registration will then be linked to the correct EE_Contact and the my events section pulls the registrations linked to the user based on the ATT_ID.

If I click the gear, those registrations show up as approved. I was reading it, based on the key, as though the green was “Pending payment.”

Its showing the individual events and then the registrations for those individual events on each row.

You could try the simple_list_table template for that shortcode:

[ESPRESSO_MY_EVENTS template=simple_list_table]

The lists individual registrations rather than sectioning them into events, does that work better?


Katelyn

December 13, 2022 at 9:35 am

And this is probably a stupid question, but where can I find the Contact ID, I’m assuming it’s a number — is it the post ID?


Katelyn

December 13, 2022 at 10:38 am

Will that have to be continuously done with that specific user? If they keep purchasing events?


Tony

  • Support Staff

December 13, 2022 at 12:01 pm

And this is probably a stupid question, but where can I find the Contact ID, I’m assuming it’s a number — is it the post ID?

Sorry, yeah. When you click on the ‘View Linked Contact’ button, the Contact ID is the post=XX in the address bar.

Will that have to be continuously done with that specific user? If they keep purchasing events?

I’m not sure I follow… if they keep registering using details that don’t match the correct contact then yes, but… that’s kinda to be expected if they don’t match their own details is it not?

The support post ‘Creating Multiple Users Upon Registration of an 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