Why can't a user register more than once, and why are the tables in the registration table set as unique?

Combined with Commerce Registration, imagine this scenario:

Site powered by Commerce/CR/Registrations creates registrations for tournament signups. In some cases, 1 coach signs up 1 team in a tournament, and there is no issue. In other cases, you have a coach who is the coach of multiple teams, and wants to register them in the same tournament.

Slots are not helpful- as these can't have signup limits. Also, each registration must be bought and processed separately, due to how the business runs their accounting/charging procedures.

I am trying to find a way to at least let the admins create new registrations for people who want more than one, but I am being stopped by Registrations, since it seems you cannot create more than one per user ID, here is the database error:

a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:1079:"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3311-commerce_product--107576' for key 'entity_id_entity_type_user': INSERT INTO {registration} (type, entity_id, entity_type, anon_mail, count, user_uid, author_uid, state, created, updated, order_id) VALUES

Comments

nicxvan’s picture

This is uncanny, I came here to post the same issue, I can confirm bug exists.

Further the following option is checked off for the product:

"If selected, users can register for more than one slot for this event."

kevinquillen’s picture

I went into SQL and removed the unique index of entity_id_entity_type_user off the table and made adjustments to the commerce pane to allow this- I haven't seen any immediate side effect of doing this yet.

There are a couple of cases here.

1 person wants to sign up a group (slots)
1 person signs up an entity (team, just 1 slot)
1 person signs up multiple entities (teams, multiple registrations)

Slots can't always control this because you may want unlimited registration with no limit.

Bricks and Clicks Marketing’s picture

I'm interested in this as well. Also wondering if 1 person registers a team, could they have some sort of control over the accounts they purchased?

rivimey’s picture

This is sort of similar to a problem I have had... parents registering their children for activities at an event. For this, I made the children's names and other details subforms of the registration, which worked, but then each registration counted as one slot and it made some aspects of rendering the result difficult.

It would be nice to track using the slot system the children (but not the parent): in my case all children are separate, not "bundled", and parents don't count: they don't attend and are only involved as guardians.

Bricks and Clicks Marketing’s picture

@rivimey: did that result in accounts for each of the children? And did the parent, as the buyer, have access to those accounts?

kevinquillen’s picture

I would think the complexity can be resolved by removing all the restrictions here, or adding to 'registration type' (Group, Individual, etc) something like that. But it's weird for users to register, then come back later and go oh yeah I need to add one more 'ticket' or what have you, and they get a big fat error.

rivimey’s picture

@arphanus: as people were registering without having to create Drupal accounts, they were doing do anonymously as far as registration was concerned, and consequently for privacy's sake, nobody but the site owners could see the details. The reg form was filled in by the parent and the children's names were added as data.

I would have preferred a "sleeker" solution but am not even sure what it would look like. The thing I didn't want was to have to create a whole load of account registrations before starting, which would have presented a user-barrier to a largely non-tech audience.

I would agree with comment #6 conclusion.

mrfelton’s picture

Exact same problem here. Either the system should accept multiple registrations for each event (the options in the registration settings seem to suggest that this should already be possible), or it should show an error message telling they can't register more than once. It definitely shouldn't end with a fatal error!

Personally, I can't see any good reason why the table needs rows to be unique in the way thats its set up now.

jason.fisher’s picture

Temporary workaround to redirect users to update their existing registration if it already exists.

modulename_init() {

  global $user;

  // Redirect users from node/%/register to register/%/edit
  if ($user->uid && arg(2) == 'register' && arg(0) == 'node') {
    $nid = arg(1);
    $node = node_load(arg(1));
    if ($node && $node->field_registration['und'][0]['registration_type'] == 'volunteer') {

      $registrations = registration_load_multiple(false, array('type' => 'volunteer', 'author_uid' => $user->uid, 'user_uid' => $user->uid, 'entity_id' => $nid));

      foreach ($registrations as $key => $registration) {
        if ($registration->registration_id > 0) {
          drupal_set_message(t('You are already registered.  You may update your registration below.'));
          header("Location: /registration/" . $registration->registration_id . '/edit?destination=node/'.$nid);
          exit();
        }
      } 
    }
  }
  // End register redirect

}
tauno’s picture

levelos’s picture

Status: Active » Fixed

The unique constraint on user registrations was removed in 521e1b99c82596857b97b241855e919ac490103a. We also altered how registration_is_registered() works as discussed in #1881212: registration_is_registered() should be smart about registration states.

nicxvan’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Category: support » bug
Status: Fixed » Active

Still getting
Email addresses must be unique for each registrant. Error
I updated today to the latest release. I did not test the dev version since it is only one day newer than the stable release.

nicxvan’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

I just realized this was posted to the dev version so I upgraded, I'm still getting the error.

I also received the following error the first attempt at updating:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://worcesterfencing.com/update.php?op=selection&token=XMQseioTigJFhN... StatusText: OK ResponseText: Fatal error: require_once() [function.require]: Failed opening required '/home/worfence/public_html/sites/all/modules/registration/includes/registration.entity.inc' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/worfence/public_html/includes/bootstrap.inc on line 3088

kevinquillen’s picture

Version: 7.x-1.x-dev » 7.x-1.0

Did you delete the unique index in the table as noted in #2?

simonjcarr’s picture

I have just upgraded the latest release of this module and am now getting this error when I checkout and am presented with the registration forms.

You cannot register yourself for the same item more than once.
Notice: Undefined property: Registration::$mail in commerce_registration_information_checkout_form() (line 74 of /var/www/vhosts/arduino-mega.com/simoncarr.co.uk/srrotary/sites/all/modules/commerce_registration/includes/commerce_registration.checkout_pane.inc).
Notice: Undefined property: Registration::$mail in commerce_registration_information_checkout_form() (line 74 of /var/www/vhosts/arduino-mega.com/simoncarr.co.uk/srrotary/sites/all/modules/commerce_registration/includes/commerce_registration.checkout_pane.inc).

As you can see as well as the error I still get the "You cannot register yourself for the same item more than once." error. I have also carried out the instruction in #2 (removed the unique index of entity_id_entity_type_user).

I have to go live with this site at the end of February so any help is much appreciated.

simonjcarr’s picture

Just to let you know that I also got an error when upgrading the registration module which prevented update.php from running. I ran manually afterwards and that sorted out the problem.

User can't register more than once? is still a problem however. I am not sure from reading the above posts if this issue has been fixed or not?

Could someone clarify what I need to do fix the error.

Thanks

simonjcarr’s picture

Just reading the above posts again and it looks as though the developers are trying the fix the problem that once a user has registered for an event once that they should then be able to register again at a later date.

My problem however is
That if I add 3 registrations to the cart and then checkout, I am presented with 3 registration forms as I would expect. If I choose Myself in more than one of them I get the User can't register more than once error. If I try to register for another person and use the same email address more than once I get the Duplicate email address error.

Can you confirm if there is a fix available this issue?

kevinquillen’s picture

Check that the unique restraint is removed from your database table, my first guess.

simonjcarr’s picture

Do I delete this completely or just change it from Unique to Index?

simonjcarr’s picture

Could someone tell me which file holds the code that prevents the same user registering twice. I have now upgraded to the Dev version and deleted the unique index as described in #2 but I still cant regisetr the same person twice.

My plan is patch the code myself and see if I can get this working.

Thanks
Simon

levelos’s picture

Status: Active » Fixed

I believe all the issues posted after #11 are related to Commerce Registration. This is an entirely different project with different maintainers, so please discuss related issues there. This thread is solely about changes to Entity Registration allowing the same user to register more than once, which, from everything we can tell, now works as designed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kevinquillen’s picture

Yes, as long as you remove the unique indexes on the table, it will allow it (I am using Commerce Registration).

mrfelton’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new678 bytes

I believe there is still an issue with this. Whilst the unique constraint has been removed, the registration_access_people() function still checks to ensure that a user is not already registered when determining if they have the permission to register for an event. The attached patch updates this so that it considered the ' Allow multiple registrations' option when determining wether to restrict based on wether the user is registered or not.

tauno’s picture

Status: Needs review » Needs work

The multiple_registrations setting is currently intended to allow a user to register for multiple slots with one registration. Probably makes sense to not mix that logic with the ability to create multiple registrations.

Could be split out into two settings - allow user to register for multiple slots and allow user to create multiple registrations.

mrfelton’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

Updated patch introduces a new setting to allow users to register for a particular more than once.

4kant’s picture

mrfelton,
tried your patch. Thanks.
I can see the tab for registering again now. But when I try to register again I get the message "You are already registered for this event."
Tried all combinations in register-settings of the entity...

Btw: as user 1 I never had restrictions in registering more than once.

selfirian’s picture

mrfelton,
Same here I tried your patch, I get the extra option but when I try to register twice for an event I get an error message.
Is there something else I have to do in order to make this work, maybe I missed something.
Thanks for any support on this, if I can help let me know.

mrfelton’s picture

Missed one bit. Patch updated. Note that if you are using this in conjunction with commerce registration, you need to patch that too as it does its own checks to see if a user is already registered. See #1974546: User can't register more than once for corresponding patch,

4kant’s picture

Thanks mrfelton, it´s working now.
I´m actually not using commerce registration but intend to soon.

Again thanks!

nhck’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for this. Tested and I hope it gets in.

levelos’s picture

Status: Reviewed & tested by the community » Fixed

A variation of the patch from #29 committed in f7054046499cf0e5f86481e4bf1ddb69327d9051. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • levelos committed 521e1b9 on 7.x-1.x, panels, any-entity, slots, integrations, hold_state
    #1861364: Remove unique constraint on individual registrations.
    
  • levelos committed f705404 on 7.x-1.x, any-entity, slots, integrations, hold_state
    #1861364 by mrfelton, levelos: Add a setting for allowing multiple...