The $user object represents a single Panel or frontend user.

How to create a $user object

Before you can call the methods of the User class, you need a $user object.

The $user object is available via the $kirby object:

The current user

$user = $kirby->user();

A specific user by user id or email address

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

The first user of the users collection

$user = $kirby->users()->first();


With the $user object in place, you can use the methods of the user class to get information about the user or modify the user object.

Check if the user is an admin

if ($user->isAdmin()) {
  echo "Hey, great, you can do anything you like!"

Convert user object to array

$userData = $user->toArray();

Change the user name programmatically


Fetch all files belonging to the user object

$userFiles = $user->files();