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


jgpr

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?


jgpr

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) {


jgpr

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.


jgpr

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.


jgpr

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.


jgpr

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.


jgpr

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?


jgpr

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?


jgpr

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?


jgpr

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).


jgpr

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.


jgpr

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.


jgpr

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 🙂


jgpr

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?).


jgpr

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


jgpr

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.


jgpr

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.


jgpr

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.


jgpr

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 🙂


jgpr

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.


jgpr

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?

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso