Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The attached patch adds migration support - with this patch, when migrating users in an environment with email_registration enabled, the username provided to the migration process will be set for each user, rather than the module's default derivation from email address, with fallback to a random username.
Comment | File | Size | Author |
---|---|---|---|
#6 | email_registration-imports.678434.6.patch | 1.08 KB | Jon Pugh |
#3 | email_registration_678434_1.patch | 1.46 KB | hadsie |
#2 | email_registration_678434.patch | 620 bytes | hadsie |
#1 | email_registration_migrate_2.patch | 1.1 KB | mikeryan |
email_registration_migrate.patch | 2.7 KB | mikeryan | |
Comments
Comment #1
mikeryanPatch updated to use the new hook_migrate_api().
Comment #2
hadsie CreditAttribution: hadsie commentedI think the second patch is missing most of the content from the original patch.
However, I think this could be solved a lot more generically. Basically I don't think the email_registration should not generate a username if the account object already has one set. There are other modules besides the migrate module that create / import users and set a user name with them.
This patch just does a simple check to determine if the username is already set, and if so then it does nothing. This also means that you don't really even need hook_email_registration_name() as any other modules that wish to override the account name can just do so in their on hook_user insert.
Comment #3
hadsie CreditAttribution: hadsie commentedForgot that /this/ module sets a random username on registration :). Here's a new patch that accounts for that.
Comment #4
thePanz CreditAttribution: thePanz commentedTested (with User Import) and works fine!
This patch fixes my #981772: Conflict with User Import issue.
Comment #5
YK85 CreditAttribution: YK85 commentedAlso, fyi #657472: Add setting to allow users to login with email address or username depends on this patch
Thanks!
Comment #6
Jon PughFeeds.module imports are also affected by this problem. Any remote login system or social network would probably be affected as well, Facebook connect, Google, etc. There is no check on the
hook_user_insert()
before it rewrites and updates the username. Basically anywhere you are creating users programatically.The Drupal 6 version was marked RTBC more than a year ago, can we get these committed? Especially since that other issue depends on it.
I updated this patch to work with Drupal 7.
I'd be happy to co-maintain this module!
Comment #7
Jon Pughmarking needs review
Comment #8
Simon Georges CreditAttribution: Simon Georges commentedWorks for me (D7 version from #6).
Comment #9
Simon Georges CreditAttribution: Simon Georges commentedComment #10
tr33m4n CreditAttribution: tr33m4n commentedAfter applying the patch at #6 my new users are being created with the username set as the random password that's generated :S
Comment #11
AaronBaumanbump.
Comment #12
andypostI think this should be implemented by different way. the module require a flag set into a property of account, this will allow ordering of the modules that affects username, email and other properties
Comment #13
leeomaraI'd like to see the patch in #6 committed. It resolves the conflict with numerous other modules that set user name (for example fboauth).
This isn't to suggest that andypost is wrong in wanting a more formal system for modules to deal with making these changes and interacting with one another, but to my mind, that is a separate issue working on a different scope of problems.
Comment #14
gregglesI visually reviewed the 6.x and 7.x patches and think they are ready to go.
I agree with leeomara's perspective in #13 that we shouldn't hold back progress in the name of perfection.
@andypost, maybe create a new issue for the feature you mention in #12 so that people who need it can work on it?
Comment #15
andypostI think yes #6 solves the problem so needs to be commited. Also I not sure that it's possible to find a universal way to fix this among all user-name related modules
Comment #16
andypostCommited and pushed to 6.x and 7.x
D6 #3 fixed trailing white-space
Comment #18
riskop CreditAttribution: riskop commentedHello Jon!
We would like to use Email Registration and LDAP modules together. Furthermore we would like usernames generated from the email address even when user is *imported from LDAP database*.
Since your patch accepted, Email registration only generates the username if the user is created via the registration form (and username is temporarily set to 'email_registration_' . user_password()). I see your point, and understand that often this is what users want. But I think there are other cases (like ours) when the former way of username generation would be preferred.
I'd like to see a configuration option for this. Something like "always generate username from email".
What do you think about it?
Best regards, Peter
Comment #19
gregglesHi riskop,
It's possible to do that in a custom module. See hook_email_registration_name.