Show fields based on userrole

Hello there,

i am developing a kirby template for a agency. We want to give the client a restricted panelacess. So we want some fieldsto be hidden for their role. I created a new role and in the templates/plugins index.php i did this:


if(kirby()->user() && kirby()->user()->role()->name() == 'client') {
    $sitedir = '/blueprints/client/site.yml';
} else {
    $sitedir = '/blueprints/site.yml';

Kirby::plugin('khepri-design/khepri-gusto', [
  'blueprints' => [
    'site' => __DIR__ . $sitedir,
. . .

But doing it like this kicks me back to the hompage after login in.
I didn’t find a working solution for this case.

Any help?


You could try this instead: Programmable blueprints | Kirby CMS

Make sure there is no site.yml blueprint in the site/blueprints folder

Thank you, this did it for me :slight_smile: I guess my Problem was that “role” was undefined because it was out of context there