$users->create()
$users->create(array $data): Kirby\Cms\User
Parameters
Name | Type | Default |
---|---|---|
$datarequired | array |
no default value |
Return type
This method modifies the existing $users
object it is applied to and returns it again.
Parent class
Examples
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();
}