Hi! Is it possible to create kirby-users from batch - in my case a excel sheet, or a flatfile.
I like to do this from a route in my Plugin.
vg Carsten
Hi! Is it possible to create kirby-users from batch - in my case a excel sheet, or a flatfile.
I like to do this from a route in my Plugin.
vg Carsten
I havent tested but something like that:
<?php
$kirby->set('route', array(
'pattern' => 'my-plugin/users/batch',
'action' => function() {
try {
$file = fopen('users.csv', 'r');
while (($userData = fgetcsv($file)) !== FALSE) {
$user = site()->users()->create($userData);
}
fclose($file);
} catch(Exception $e) {
echo $e->getMessage();
}
}
));
Thanks for the reply
Looks good, but i do not have the $site Varibale. Hmmm…
You can use site()
instead.
Works great! thank you.