Create Kirby Users

Hi! :slight_smile: 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:


$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);
        } catch(Exception $e) {
            echo $e->getMessage();
1 Like

Thanks for the reply :slight_smile:

Looks good, but i do not have the $site Varibale. Hmmm…

You can use site() instead.

1 Like

Works great! thank you.