Reference

Guide

$kirby->impersonate()

Become any existing user

$kirby->impersonate(string $who = null): Kirby\Cms\User|null

Parameters

Name Type Default Description
$who string null

Return type

Kirby\Cms\User|null

$who

There are three options for the $who parameter:

  • kirby (impersonates the allmighty with full permissions)
  • a username (impersonates the specific user with its permissions)
  • null (resets the impersonation)

Example

<?php

$kirby = kirby();
$kirby->impersonate('kirby');

page('notes/a-great-article')->update([
  'author'  => 'Homer Simpson'
]);

Source code

kirby/src/Cms/AppUsers.php#L42