User field - how to fetch custom fields from user blueprint?

Hi there

In my template it renders the email-adress of the selected user. I guess this is the standard behaviour without a custom user blueprint. Since I want to render the Nickname of that user, I created a custom user.yml with a nickname field. Now: how can I fetch this nickname-field in my template? I tried:

<?= $user->nickname() ?> and <?= $user->test()->nickname() ?> without success.
(test is the name of my test-user)

How would I correctly fetch the nickname-field?

Are we talking about getting the user from a users field here? If so, then you have to get a user object from the stored value first using the toUser() method:

<?php
if ($user = $page->fieldNameWhereUserIsStored()->toUser()) {
  echo $user->nickname();
}

Yes, and your solution worked, thanks :+1:

I arranged it a bit more kirby-like, if you don’t mind :jack_o_lantern:

<?php if ($user = $article->musica_author()->toUser()): ?>
<?= $user->nickname() ?>
<?php endif ?>