Reference

$users->create()

$users->create(array $data): /docs/reference/objects/file/asset

Parameters

Name Type Default Description
$data array

Return type

/docs/reference/objects/file/asset

Example

try {

  $user = $kirby->users()->create([
    'name'      => 'john',
    'email'     => 'john@doe.com',
    'password'  => 'secretpasswordwillbeencrypted',
    'language'  => 'en',
    'role'      => 'editor',
    'content'   => [
      'birthdate' => '1989-01-29'
    ]
  ]);

  echo 'The user "' . $user->name() . '" has been created';

} catch(Exception $e) {

  echo 'The user could not be created';
  // optional error message: $e->getMessage();

}

Source code

kirby/src/Cms/Users.php#L27