Replies: 1 comment
-
Hey. Simplest way to do it is by creating a command that imports the users from wherever they currently are (DB, CSV etc.). Check the docs on creating users. Here's an example from a command I wrote that imports users from a CSV: use Statamic\Facades\User;
$csv = 'users.csv';
$file = fopen($csv, 'r');
while (($row = fgetcsv($file)) !== false) {
$user = User::make()
->email($row[1])
->data([
'name' => $row[0),
]);
$user->password($row[2]);
$user->roles(...);
$user->groups(...);
$user->save();
}
fclose($file); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For a website migration to Statamic+Membersbox project I have to create 250 member invites.
The only strategy I found so far is to manually create every member in the Statamic backend. While this is time consuming, there is also the risk of human mistakes I want to avoid (e.g. missing to invite members).
What is the simplest strategy to batch create the users with a script? Is there a simple sequence of API calls I can use (simpler then trying to recreate MembersController.php:store)?
Thank you so much for your support!
Beta Was this translation helpful? Give feedback.
All reactions