Become any existing user or disable the current user
||User ID or email address,
||Optional action function that will be run with
the permissions of the impersonated user; the
impersonation will be reset afterwards
There are four options for the
- a username (impersonates the specific user with their permissions)
'kirby'(impersonates the allmighty user with full permissions)
'nobody'(disables the currently logged in user, added in Kirby 3.5.0)
null(resets the impersonation)
The impersonation will be active for all code that runs in the current request after the call to
$kirby->impersonate(). If you want to limit the impact to a single operation, call the method with a callback (see below).
If you only want a single operation to run with different privileges, use a callback:
The impersonation automatically gets reset to the previous value after the callback returns.