Bulk-import members from CSV
Each row becomes an account, created exactly like exp:user:create. No password travels in the file.
What you'll have at the end
The members of your list as accounts in the right groups, each with an activation mail or disabled until you set a password.
Before you start
- The list as a spreadsheet, with one row per person.
- The name or node id of the group the members belong to, here
Members.
Steps
Save the list as a CSV file in UTF-8, with this header row:
login,email,first_name,last_name,groups jdoe,[email protected],Jane,Doe,Members rroe,[email protected],Richard,Roe,groupsmay stay empty; then--groupdecides. Several groups are separated by|.Remove any password column. A file with a password column is refused.
Copy the file to the server, for example to
var/tmp/members.csv.Run the import as a dry run.
./console exp:user:import var/tmp/members.csv --group=Members --send-activationEvery row is checked. Each row shows
would_create,skipped(the login exists) orrefusedwith the reasons.Fix the refused rows in the file, and run the dry run again.
Run the import with
--apply../console exp:user:import var/tmp/members.csv --group=Members --send-activation --applyEach person gets the activation mail.
Data protection: The file holds names and e-mail addresses. Delete it from the server when the import is done.
Result
exp:user:list --group=Members --state=unactivated lists the new accounts until the people activate them.
Variants
- No mail now: use
--disabledinstead of--send-activation. When the members may start, enable the accounts withexp:user:bulk enable, then send each person the reset link withexp:user:reset-password --send-link. - JSON instead of CSV: an array of objects with the keys
login,email,first_name,last_name,groups, and--type=json. - A large list: split it into files of a few hundred rows. A run that stops can be repeated: existing logins are skipped.
Related pages
- Import, export and bulk changes
- Approve registrations: reminders with
exp:user:resend-activation.