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.
Comment | File | Size | Author |
---|---|---|---|
#5 | 3027552-fix-incompat-with-username-altering-modules.patch | 2.49 KB | gonssal |
#2 | get_user_by_mail-3027552-2.patch | 1.16 KB | PieterDC |
Comments
Comment #2
PieterDCAttached patch.
Comment #3
PieterDCComment #4
gonssalI'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 thegetUid()
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.Comment #5
gonssalI needed a patch for my automated deployment so here it goes.
Comment #6
gonssalComment #7
brooke_heaton CreditAttribution: brooke_heaton as a volunteer commentedI'm using email_registration and this is an issue for me. Patch #5 worked like a charm for me.
Comment #8
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedComment #9
lamp5It needs a reroll and basically we should add role and block or activate user. Right now we only add role for action without approval.
Comment #11
lamp5