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)
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();
}