In Kirby 2 I can code:
<?php if($user = $site->user() and $user->hasPanelAccess()): // user is logged in and has panel access ?>
If I write in Kirby 3:
<?php if($user = $kirby->user() and $user->hasPanelAccess()): // this is always true ?>
this did not work as expected. Look at the comments!
That’s because there is no hasPanelAccess()
method
if($kirby->user('someone@example.com')->role()->permissions()->for('access', 'panel')) {
// do something but don't forget to check if there is a user before calling the role method
}
Thank you @texnixe, your code is super as always.
I use now:
<?php if($user = kirby()->user() and $user->role()->permissions()->for('access', 'panel')): // user is logged in and has panel access ?>
// do something
<?php endif ?>