Call to undefined function ()

I’m getting the following error and I have no idea why. Can anyone help me?


$user = $kirby->user();

if (!$kirby->user() || ($user->role()->id() != 'jugendleiter' && !$user->role()->isAdmin())): ?>

Logged-in users only!

<?php else: ?>

You shall pass!

<?php endif ?>

<?php snippet('footer') ?>

Seems there was some weird whitespace after the ||. After deleting it and entering a new space it worked :-/

Hm, looks ok, but I think the code is not really very clear:

if ( ! $user || ! in_array($user->role()->name(),  ['jugendleiter', 'admin']) ) : ?>

Thanks for your suggestions for improving my code @texnixe! :slight_smile: