Skip to content

Kirby 3.7.5

$users->create()

$users->create(array $data)

Parameters

Name Type Default
$data * array

Parent class

Kirby\Cms\Users

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();

}