Events Made Easy › Forums › How do I … › Limit to 1 registration
- This topic has 23 replies, 3 voices, and was last updated 10 years, 5 months ago by Franky.
-
AuthorPosts
-
Fri 16 May 2014 at 15:28 #52186AnonymousInactive
Is there a way to prevent someone from registering multiple times for a specific event? Is there a check that can be done on a field to determine if that same field content exists and, if so, reject the registration?
ThxSun 18 May 2014 at 00:16 #52187AnonymousInactiveYou can achieve this using the placeholders and accomplish what you want. My Event format has the following:
#_ADDBOOKINGFORM_IF_NOT_REGISTERED
#_REMOVEBOOKINGFORM_IF_REGISTEREDIf they’re already registered, it gives them the form to cancel their registration. If they aren’t already registered, then they get the form for signing up.
If you only use the first one, it will essentially remove the signup form if they’ve already signed up. That should get you want you need. Just find the space in your form where there’s the placeholder #_ADDBOOKINGFORM and add the _IF_NOT_REGISTERED to it.
Sun 18 May 2014 at 17:44 #52188FrankyKeymasterThanks Feegle, totally correct.
Also: check out the option “Require WP membership” when creating an event.
And there are the conditional tags you can use, see #_IS_REGISTERED here: http://www.e-dynamics.be/wordpress/?cat=24Mon 19 May 2014 at 17:41 #52189AnonymousInactiveThanks guys! I forgot to mention that users do not need to have a WP account to sign up… This registration is for an assessment that people sign up for on a “1st come, 1st served” basis. I just don’t want someone to sign up repeatedly, filling up the available seats… So it doesn’t look like the #_ADDBOOKINGFORM_IF_NOT_REGISTERED and #_IS_REGISTERED will work.
ThxMon 19 May 2014 at 17:48 #52190AnonymousInactiveSince EME has a record of the specific event that a user signed up for, isn’t there a way to test against that specific user/event pair using a given field (i.e. email address or last 4 of SS#) if they try to sign up again?
ThxMon 19 May 2014 at 23:43 #52195FrankyKeymasterWhat you want is to check if the user already registered *after* he tries to register again, but before the info is entered in the db.
The eme_eval_booking_form_filter is what you want, but I just realized it needs to be changed: for now the person doing the booking is first recorded in the db and only afterwards the evaluation is done. When the eval fails, a person is in the DB for no reason. To keep the old behavior, I added a new filter called eme_eval_booking_filter.
Example usage (put this in your theme functions.php when the next release is there):add_action('eme_eval_booking_filter','do_my_stuff'); function do_my_stuff($event) { $event_id=$event['event_id']; $already_registered=0; // only do a specific event if ($event_id != 5) return; // get all attendees $attendees = eme_get_attendees_for($event_id); foreach ( $attendees as $attendee ) { // $attendee['person_email'], $attendee['person_name'] $bookerEmail = eme_sanitize_html(stripslashes_deep($_POST['bookerEmail'])); $bookerName = eme_sanitize_html(stripslashes_deep($_POST['bookerName'])); if ($bookerEmail == $attendee['person_email'] && $bookerName == $attendee['person_name']) $already_registered=1; } if (!$already_registered) { // eval is success return array(0=>1,1=>''); } else { // bad form entry return array(0=>0,1=>'Already registered'); } }
Mon 2 Jun 2014 at 15:27 #52302AnonymousInactiveNow that version 1.44 is out, is this something that’s integrated into the plugin, or do I still need to put it in functions.php?
What happens if a user is already registered? Is something shown after they click to register?
ThxMon 2 Jun 2014 at 15:35 #52303AnonymousInactiveWell, as a test, I added that code to the functions.php file. It resulted in the site not working with nothing being displayed on any page…
Mon 2 Jun 2014 at 15:51 #52305FrankyKeymasterThe eval filter stays.
If nothing is displayed, it usually indicates a php error somewhere (might be a bug of me of course). Check the apache log files for errors, I’ll test this later on too.
Edit: I fixed the example, should work now.Mon 2 Jun 2014 at 17:45 #52307AnonymousInactiveI inserted your corrected code but I can still register multiple times for the same event (I have deactivated and activated the plugin).
ThxMon 2 Jun 2014 at 18:46 #52308FrankyKeymasterDid you use the correct event ID?
Reason why I don’t implement it in EME directly is that, since you don’t require WP membership, it’s easy to just change a letter in tthe name and register again …Mon 2 Jun 2014 at 18:51 #52309FrankyKeymasterAnd also: check the “quotes” for the add_action line in your functions.php. I saw that they were not the correct quotes, so … corrected the example again.
Edit: tested this example code and it works as intended. Also added it to the doc as an example usage for the filters.Mon 2 Jun 2014 at 20:31 #52316AnonymousInactiveNo, I used the code as is! That means that if I have more than 1 event open for registration, I can have this check run for only 1 of the events of my choosing?
Can’t the event_id correspond to the event that they’ve clicked on the link to sign up for (#_EVENTID)?
Even with the slim chance that someone would change just a letter in their name or email address, it’s better than nothing. The risk of someone signing up more than once is reduced now that the form doesn’t come back on screen after a successful registration…
Thx
Mon 2 Jun 2014 at 20:39 #52317FrankyKeymasterIf you want it for all events, just leave the check for the event id out of it. So remove the line
if ($event_id != 5) return;
Mon 2 Jun 2014 at 21:09 #52318AnonymousInactiveIf I leave out the test for the event they’re signing up for, then their registration would be rejected regardless of which event they’ve already signed up for… They could be signed up for event A then try to sign up for event C and be rejected.
Let’s say I have 3 events: A, B and C. User1 signs up for event A and B. The only one they can still sign up for is C… The only way to check this is if the pair User1/EventA – User1/EventB – User1/EventC is tested. The info for User1 that would be used for the check would be name and email address (or any other user specific data).
Mon 2 Jun 2014 at 22:43 #52319FrankyKeymasterDid you test this? The example code posted still takes the event id into account, so it should work just fine.
Wed 4 Jun 2014 at 21:49 #52331AnonymousInactiveYes I have… I commented out this line “if ($event_id != 5) return;” then registered 3 times for the same event.
Thu 5 Jun 2014 at 17:27 #52332FrankyKeymasterJust tested this and it works just fine: it prevents double registrations for all events. If it doesn’t work for you, post the code you use.
Mon 16 Jun 2014 at 15:21 #52492AnonymousInactiveI have just tried registering twice for the same event and was successful in doing so… The code I have in my theme’s functions.php is:
// EME plugins add_action(‘eme_eval_booking_filter’,’do_my_stuff’); function do_my_stuff($event) { $event_id=$event['event_id']; $already_registered=0; // only do a specific event // if ($event_id != 5) return; // get all attendees $attendees = eme_get_attendees_for($event_id); foreach ( $attendees as $attendee ) { // $attendee['person_email'], $attendee['person_name'] $bookerEmail = eme_sanitize_html(stripslashes_deep($_POST['bookerEmail'])); $bookerName = eme_sanitize_html(stripslashes_deep($_POST['bookerName'])); if ($bookerEmail == $attendee['person_email'] && $bookerName == $attendee['person_name']) $already_registered=1; } if (!$already_registered) { // eval is success return array(0=>1,1=>''); } else { // bad form entry return array(0=>0,1=>'Already registered'); } }
Thx
Mon 16 Jun 2014 at 17:09 #52493FrankyKeymasterMake sure that the lines are in fact (check the “>” character in your code)
return array(0=>1,1=>'');
In your posted code it was (I corrected the code) the html equiv of the “>” character was being used, so maybe that is also the case in your code?
(probably because of a copy/paste with your browser). Also with the other return-line.
Edit: in fact, check the whole function to see if it is syntactically correct.
Mon 16 Jun 2014 at 19:29 #52494AnonymousInactiveI’m not really a coder but from what I can gather, I don’t see anything wrong with the code itself… Here’s a link to a screen shot of what I have: http://imgur.com/3AbWIv9
Mon 16 Jun 2014 at 23:18 #52495FrankyKeymasterI don’t see anything wrong here. Can you send an admin account so I can check on your side?
Tue 17 Jun 2014 at 15:30 #52496AnonymousInactiveSent email with login info…
Wed 18 Jun 2014 at 16:44 #52502FrankyKeymasterFor completeness: was just wrongfully pasted in the functions.php file, the code works as expected.
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.