Events Made Easy Forums How do I … Limit to 1 registration

Viewing 24 posts - 1 through 24 (of 24 total)
  • Author
    Posts
  • #52186
    Anonymous
    Inactive

    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?
    Thx

    #52187
    Anonymous
    Inactive

    You can achieve this using the placeholders and accomplish what you want. My Event format has the following:

    #_ADDBOOKINGFORM_IF_NOT_REGISTERED
    #_REMOVEBOOKINGFORM_IF_REGISTERED

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

    #52188
    Franky
    Keymaster

    Thanks 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=24

    #52189
    Anonymous
    Inactive

    Thanks 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.
    Thx

    #52190
    Anonymous
    Inactive

    Since 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?
    Thx

    #52195
    Franky
    Keymaster

    What 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');
        }
    }
    
    #52302
    Anonymous
    Inactive

    Now 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?
    Thx

    #52303
    Anonymous
    Inactive

    Well, 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…

    #52305
    Franky
    Keymaster

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

    #52307
    Anonymous
    Inactive

    I inserted your corrected code but I can still register multiple times for the same event (I have deactivated and activated the plugin).
    Thx

    #52308
    Franky
    Keymaster

    Did 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 …

    #52309
    Franky
    Keymaster

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

    #52316
    Anonymous
    Inactive

    No, 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

    #52317
    Franky
    Keymaster

    If 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;

    #52318
    Anonymous
    Inactive

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

    #52319
    Franky
    Keymaster

    Did you test this? The example code posted still takes the event id into account, so it should work just fine.

    #52331
    Anonymous
    Inactive

    Yes I have… I commented out this line “if ($event_id != 5) return;” then registered 3 times for the same event.

    #52332
    Franky
    Keymaster

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

    #52492
    Anonymous
    Inactive

    I 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

    #52493
    Franky
    Keymaster

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

    #52494
    Anonymous
    Inactive

    I’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

    #52495
    Franky
    Keymaster

    I don’t see anything wrong here. Can you send an admin account so I can check on your side?

    #52496
    Anonymous
    Inactive

    Sent email with login info…

    #52502
    Franky
    Keymaster

    For completeness: was just wrongfully pasted in the functions.php file, the code works as expected.

Viewing 24 posts - 1 through 24 (of 24 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top