Hide parts of the panel for user role

You can define that via the access permission in the user blueprint.

For that the best option currently is to use blueprints based on user role in your index.php.

<?php

require __DIR__ . '/kirby/bootstrap.php';

$kirby = new Kirby();
$user  = $kirby->user();

if ($user && $user->role() == 'candidate') {
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => __DIR__ . '/site/blueprints/candidate',
       ],
   ]);

} elseif ($user && $user->role() == 'sponsor') {
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => __DIR__ . '/site/blueprints/sponsor',
       ],
   ]);
}

echo $kirby->render();

You could also use models in combination with before hooks.

1 Like