Skip to content

Kirby 3.8.4

User::create()

Creates a new User from the given props and returns a new User object

User::create(array $props = null): Kirby\Cms\User

Parameters

Name Type Default
$props array null

For the $props parameter, you pass an array with the following data, which will be used to set up the Kirby\Cms\User object:

Name Type Description
blueprint array Sets the Blueprint object
content array Sets the Content object
email string Sets the user email
files array Sets the Files collection
id string Sets the user id
language string Sets the user language
name string Sets the user name
password string Sets the user's password hash
role string Sets the user role
translations array Create the translations collection from an array

Return type

Kirby\Cms\User

Parent class

Kirby\Cms\User

Example

$newUser = User::create([
  'email'     => 'bastian@getkirby.com',
  'name'      => 'Bastian',
  'role'      => 'admin',
  'language'  => 'en',
  'password'  => 'topSecret',
  'content'   => [
    'mastodon'  => 'https://mastodon.social/@getkirby',
    'position'  => 'founder'
  ]
]);