I work at a web agency, where we mostly use Craft CMS to build websites. For each website, the same group of people needs access to the control panel. We could manually create their user accounts. Or we could automate it, and play foosball with the time we saved.
Craft CMS content migrations is the perfect tool for the job. We’ll use migrations to populate the database with a predefined list of users. I suggest you take a look at the documentation, if you’re not already familiar with content migrations.
To create the migration, run the following command in your terminal:
This will create a new migration file in the migrations folder.
I added an array of users to the safeUp method, then loop through the array, and create the users.
The createUser method adds the users to the database.
Execute the migration by running ./craft migrate/up. The users can now login with their email address as password. But only in a local environment. They are forced to set a new password in production or development.