Support

Home Forums Event Espresso Premium Unique emails upon registration – errors

Unique emails upon registration – errors

Posted: March 16, 2024 at 2:08 am

Viewing 10 reply threads


b2bvulcanusfest

March 16, 2024 at 2:08 am

Hi,

I am using the snippets from ‘Unique emails upon registration’ ticket.
https://eventespresso.com/topic/unique-emails-upon-registration/

But in Jqeury script I have an error:

cannot read properties of undefined (reading ‘substr’)

Can you help since this is very significant add on feature for your module!


Rio

  • Support Staff

March 20, 2024 at 8:22 pm

Hello,

That example is not from EE, but you can check our snippet here, we used different approach though.
https://gist.github.com/Pebblo/eabb317ca126f5b298eca78755f2cbd1

You can also contact developers here for some modification needed.
https://eventespresso.com/developers/event-espresso-pros/

thanks


b2bvulcanusfest

March 24, 2024 at 2:07 am

I see your snippet is only for logged in users. Is that right?

And if yes, please just describe to me what approach needed to make it for all visitors? Just to avoid spending time in documentation please guide in short…


Rio

  • Support Staff

March 24, 2024 at 7:16 pm

The snippet is to remove a ticket from the ticket selector is the current use already has a registration on that ticket linked to their contact.

You can copy and paste the code to your child theme, but the best solution is to create a specific plugin and put it there.
https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

thanks


b2bvulcanusfest

March 26, 2024 at 1:40 am

Hi Rio, you have just answered me what I assumed.

Since I really do not have time and I expected before purchasing the whole package that this kind of thing will be implemented as integrated option – I just need from you or your developers a HINTS (methods and functions) how to approach for event registration WITHOUT wordpress user logged in needed (for events without logged in user constraints).

Thats all. I will then adjust the plugin/snippet…


Rio

  • Support Staff

March 26, 2024 at 5:24 am

Awesome, if you need anything, feel free to reach us again. Have a wonderful day!


b2bvulcanusfest

March 26, 2024 at 9:38 am

Yes Rio I need. Third time I am asking:

need from you or your developers a HINTS (methods and functions) how to approach for event registration WITHOUT wordpress user logged in needed (for events without logged in user constraints).


Tony

  • Support Staff

March 26, 2024 at 10:41 am

Hi there,

Without writing this code for you, I’m not sure what ‘hints’, methods or functions I can provide here.

We don’t police registrations in the way you are trying to, so there is no function/method for checking if the current registration data matches a current registration on the event within core that I can point you to, you need something custom. It’s also easily bypassed with various email naming methods (email being what you would need to consider ‘unique’ here) such as tony@example.com and tony+1@example.com, that’s just bypassed your checks and allows for multiple registrations.

The only ‘real’ way you are going to be able to limit registrations to prevent people from registering multiple times is to force login.

The original snippet you linked to uses the .big-event-title-hdr element to discover the Event ID. You’re likely getting the above error becuase you are selecting just 1 ticket from an event and EE then doesn’t display that element on the page.

It’s the difference between this: https://monosnap.com/file/Ut8bgnHqN4X7v6xwcaf029OJtwVvDv
(Selecting a single ticket in EE)

And this: https://monosnap.com/file/0fnXBU8qCKhQeyHenlC6U2hWepUVMj
(Selecting 2 or more tickets)

That element is used by the snippet to find the Event ID: https://monosnap.com/file/Drh5yYNd4toXVjoq64ZgADi4Cvlt7I

You’ve asked for some hints and personally, I’d look at doing this another way. I’d use the AHEE__Single_Page_Checkout__process_reg_step__attendee_information__process_reg_step hook to hook into the SPCO checkout process and check for current registrations from there, then return and error stating the user already registered.

I don’t have an example of doing what you are trying to do, partially because of the reasons I mentioned above but I do have an example of using that hook here:

https://gist.github.com/Pebblo/0b3b28c9d0c52d5425fa167da1f1a622#file-spco_hook_example-php-L1-L41

You can then loop over the registrations within valid_data and compare the values of those with previous registrations using the model system to pull in the details you need:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System


b2bvulcanusfest

March 26, 2024 at 10:56 am

Thank you very much for detailed ‘hints’ 🙂

Regard the bypassed emails – since registrant will get the ticket on email he need to use the real ones. Also since we are doing closed B2B events all registrants are checked and approve after (this also I needed to do some customization for your process) so it is helpful for me to at least prevent several persons coming to event with single email…


Tony

  • Support Staff

March 26, 2024 at 12:38 pm

Regard the bypassed emails – since registrant will get the ticket on email he need to use the real ones.

All of the emails I gave you are valid.

tony@example.com
tony+1@example.com
tony+s0m3tH1nG@example.com
tony@anotherexample.com

They are all valid emails which could still all be mine, the first 4 all would likely go to the same inbox but would bypass any validation you have checking identical email addresses (sure you could stip out the +{string} up to the @ sign but where do we stop).

Also since we are doing closed B2B events all registrants are checked and approve after (this also I needed to do some customization for your process) so it is helpful for me to at least prevent several persons coming to event with single email…

Great! I hope this works well for you.

Any further questions just let me know 🙂


b2bvulcanusfest

March 31, 2024 at 1:18 pm

Hi…

I had time a little to try something and I hope you can just answer me easy… In the code I mark where need help 🙂

function attendee_information__process_reg_step($process_reg_step, $reg_step, $spco) {
// Pull the transaction from checkout.
$transaction = $spco->checkout->transaction;
// Sanity check to confirm we have a transaction
if($transaction instanceof EE_Transaction) {
// since I just allow primary registrations 1
$primary_registration = $transaction->primary_registration();
if ($primary_registration instanceof EE_Registration) {
$eventid = $primary_registration->event_ID();

// THIS PART I NEED HELP – HOW TO GET USER EMAIL FROM THE FORM
$email_check = $reg_form_data->get_input_value(’email’)

$emails = $wpdb->get_results(‘SELECT ATT_email FROM wp_2_esp_attendee_meta meta
INNER JOIN wp_2_esp_registration reg ON meta.ATT_ID = reg.ATT_ID
WHERE reg.EVT_ID = ‘.$eventid
);
foreach ($emails as $email)
{
if ($email == $email_check)
{
$registered = ‘true’;
break;
}
}
}
}

}

// Halt processing, add an error.
if( $registered ) {
$error = ‘User email already registered for the event’;
EE_Error::add_error(esc_html__($error, ‘event_espresso’), __FILE__, __FUNCTION__, __LINE__ );
}

// Always return process
return $process_reg_step;
}

add_filter(‘FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process’,’attendee_information__process_reg_step’, 10, 3);


Tony

  • Support Staff

April 1, 2024 at 4:28 am

Why have you changed the hook in use? By doing so you’ve broken the code.

FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process

Has totally different arguments to the hook I used in my original function, your function arguments now don’t match the expected objects.

$spco is no longer an instance of SPCO but an EE_Registration object which means:

// Pull the transaction from checkout.
$transaction = $spco->checkout->transaction;

Is no longer valid is as there isn’t a checkout property on an EE_Registration object, so then no code runs.

FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process

Can indeed be used, but runs after the registrations have been created within the database do you want to process data before that?

$email_check = $reg_form_data->get_input_value(’email’)

Where is this from? $reg_form_data doesn’t exist within that function.

Viewing 10 reply threads

The support post ‘Unique emails upon registration – errors’ 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