I am importing users from a system that did not force users to supply an email address. Many users did not. I would like to have an option to replace blank/invalid email addresses with a default, such as the site email address.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | user_import.module.test | 58.51 KB | cliffdiver1 |
Comments
Comment #1
DrewMathers commentedDrupal does not allow two users with the same email address. The requested feature cannot be implemented. I have changed the status to support request. Any ideas on how to handle the above situation?
Comment #2
davidwhthomas commentedI did a similar thing just now to import users without email addresses, I gave them a generated address like
blank1a2d7e@nomail.comHere's the code to change to:
user_import.module line 1537hope that helps,
regards,
DT
Comment #3
robert castelo commentedOr you could just generate the dummy email addresses in your speadsheet before importing.
Comment #4
cliffdiver1 commentedI like your code snippet but can't get it to work. It would be extremely beneficial for me since I will be doing imports without email addresses very often.
Should this code be used INSTEAD OF line 1537? When I do that, my entire site breaks and gives me an error referencing line 1551 which is the code beginning with Default:
default:
_user_import_process($import);
drupal_set_message(t('Imported'));
break;
Any ideas?
Comment #5
davidwhthomas commentedNo, the line number is obviously different in your version.
You'll need to look for the relevant lines and replace them with the code snippet.
search for
$email = trim($data[$column_id]);or perhaps it's
$errors = _user_import_validate_email($email);and insert the create email snippet from the above code.
Comment #6
cliffdiver1 commentedThanks for the quick response. Neither of those lines exists, though, in my version. I'm attaching that file (it's from 6.4) here.
Can you point me to the relevant line #?
Line 1537 in the unmodified file is:
$import['valid'] = 0;
Comment #7
jenniferannwalsh commentedI am pretty useless with Excel so I used this tool to generate almost 6,000 fake email addresses for my import: http://identitygenerator.com/
Just thought I'd post it here since I kept coming back to this thread as I tried to figure this out.
Thanks to Robert for the module!
Jen
EDIT: Note - After I wrote this I did a test import and noticed that some of the emails generated by the above tool had semi-colons in them. It was pretty easy to get rid of them with search & replace but thought I'd warn others about it.
Comment #8
Wassim Ghannoum commentedi fixed this issue by commenting the line 451 in user_import.module:
if ($values['field_match'] == 'user-email') $email = TRUE;and then i added
$email = TRUE;Comment #9
wusel commentedMy tipp:
use the UID of the user and add "@example.com", when you build the fake-email-adress in #2. The UID is always unique.
Or create the users like http://drupal.org/node/1285276 (you don't need "Wusel_Step2_MemberlistMigration" at 'Import new users and their "Profile2"-fields from one CSV-file') and import an CSV-file with empty email-fields for that users!
Good luck!