exp:expuserimport
Import accounts from a CSV or JSON file, each created as exp:user:create creates it, with the activation mail or disabled; never a password from the file (a dry run that checks every row unless --apply).
Script bin/php/expuserimport.php, code in kernel/private/classes/commands/expuserimport.php. Run it from the installation root, as the user the web server runs as:
./console exp:expuserimport --help
./console exp:user:import --help
php bin/php/expuserimport.php --helpHelp text
Import accounts
Reads a CSV file (a header line with the columns login, email, first_name, last_name, groups) or a
JSON file (an array of objects with the same keys); groups are node ids or names separated by |,
and a row without groups goes to --group. Each account is created exactly as exp:user:create
creates it. Choose --send-activation (every person gets the activation mail and sets a password
with "Forgot password") or --disabled (the accounts start disabled; reset their passwords later).
A file with a password column is refused: an import never takes passwords. A login that exists
already is skipped; a login twice in the file is refused. Without --apply every row is checked
and nothing is created.
./console exp:user:import members.csv --group=Members --send-activation
./console exp:user:import members.csv --group=Members --send-activation --apply
./console exp:user:import staff.json --disabled --apply --format=jsonOptions
| Option | Value | Help |
|---|---|---|
--type | required | The file type: csv (default) or json; import reads it from the file name when not given |
--group | required | A user group by node id or name: list, export and bulk take only its members (below it, at any depth); create and import: the group of the new accounts (repeat for more, the first is the main group; default [UserSettings] DefaultUserPlacement) |
--send-activation | Create the account disabled and send the activation mail; the person sets a password with "Forgot password" | |
--disabled | Create the account disabled (enable it later with exp:user:enable) | |
--apply | Make the change; without it the command only lists what it would change (a dry run) | |
--dry-run | The default, kept for scripts that pass it: list what would change, change nothing | |
--as | required | Act as this user (login, e-mail or id; default the user of [UserSettings] UserCreatorID); the audit records it as who did it |
--format | required | text (default) or json (the machine output exp-user/1) |
Read from the option definitions in the code (startup(), getOptions(), options() or ezcConsoleOption). Every script also takes the standard options of the script framework (--help, --siteaccess, --debug, --quiet, --allow-root-user ...).
Arguments: [file].
Related
Generated by ./console exp:help:examples from bin/php/expuserimport.php, kernel/private/classes/commands/expuserimport.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.