Skip to content

Kirby 3.8.4

$user->update()

Updates the user data

$user->update(array $input = null, string $languageCode = null, bool $validate = false): Kirby\Cms\User

Parameters

Name Type Default
$input array null
$languageCode string null
$validate bool false

Return type

Kirby\Cms\User

This method does not modify the existing $user object but returns a new object with the changes applied. Learn more →

Parent class

Kirby\Cms\User

Example

try {

  $kirby->user('bastian@example.com')->update([
    'firstName' => 'Bastian',
    'lastName'  => 'Allgeier'
  ]);

  echo 'The user has been updated';

} catch(Exception $e) {

  echo 'The user could not be updated';
  // optional reason: echo $e->getMessage();

}

This method only updates the content in the user.txt file. To update the user email or the user name, use the $user->changeEmail() or $user->changeName() methods.