I’ve created a Frontend-Authentication on my website and i would allow authentication only to a specific user role. Is this possible with Kirby ?
Yes. You can use the hasRole()
method to check if a user that is logged in has a certain role: https://getkirby.com/docs/cheatsheet/user/has-role
/* First, check if there's a user at all :) */
<?php if($user = $site->user()): ?>
<?php if($user->hasRole('myRole')): ?>
User has role :)
<?php else: ?>
User hasn't the role.
<?php endif ?>
<?php endif ?>
1 Like
If you also want to put a lock on all assets on those pages, check out the asset firewall cookbook recipe.