Problem/Motivation

When using this module in combination with https://www.drupal.org/project/email_registration
Notice: Undefined offset: 0 in getUid() (line 127 of /var/www/html/docroot/modules/contrib/select_registration_roles/select_registration_roles.module) gets thrown because Select Registration Roles searches for the user in the database based on username while Email Registration first provides a temporary user name at form rendering and then automatically generates a user name based on the entered email address at form submit.

Proposed resolution

Search the user based on email address instead of user name. AFAIK there are no modules that change the email address a user entered at the user registration form (because that mail address is to be used for mail communication sent from a Drupal site).

Remaining tasks

Normally I'd say: test coverage. But as (currently) has no test coverage whatsoever, it's a bit hard to block this on that.

User interface changes

None.

API changes

This module its getUid() now takes an email address as argument instead of user name.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PieterDC created an issue. See original summary.

PieterDC’s picture

Attached patch.

PieterDC’s picture

Assigned: PieterDC » Unassigned
Status: Active » Needs review
gonssal’s picture

Status: Needs review » Needs work

I'm having this exact same issue with email_registration and, after checking how it works, I found that in the submit function, $form_state has the uid element.

So basically you can do $uid = $form_state->getValues()['uid']; and get rid of the getUid() function.

Would you like to check if that's also the case for you and send a new patch? It would also be nice to check if the $user object is properly loaded and show an error message if not.

gonssal’s picture

I needed a patch for my automated deployment so here it goes.

gonssal’s picture

Status: Needs work » Needs review
brooke_heaton’s picture

I'm using email_registration and this is an issue for me. Patch #5 worked like a charm for me.

Andrew Answer’s picture

lamp5’s picture

Version: 8.x-1.2 » 8.x-1.x-dev
Status: Needs review » Needs work

It needs a reroll and basically we should add role and block or activate user. Right now we only add role for action without approval.

  • lamp5 committed 4347713 on 2.0.x
    Issue #3027552 by PieterDC, gonssal: Fix incompatibility with modules...
lamp5’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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