Skip to content

$field->toUser()

Converts a user email address to a user object

$field->toUser(): Kirby\Cms\User|null

Return type

Kirby\Cms\User|null

Example

Text file

Title: My great article
----
Author: author@company.com

Template

<?php if ($author = $page->author()->toUser()): ?>
<aside class="author">
  <h2><?= $author->name() ?></h2>
  <?= $author->bio()->kirbytext() ?>
</aside>
<?php endif ?>