Custom blueprint for different roles

Hi David,

Check this example, it allows you to switch to different panel according to the user role.
It use the “custom folder setup” Kirby concept to choose which blueprint folder will be used by Kirby
“candidate” and “evaluator” are custom roles created in /site/blueprints/users/
“blueprintcandidate” and “blueprintevaluator” are folder created in site/ to host panel config files

This code must be added into the index.php file

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

$kirby = new Kirby();

$current_user = $kirby->user();

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

elseif ( $current_user && $current_user->role() == 'evaluator' ):
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => __DIR__ . '/site/blueprintevaluator',
       ],
   ]);
endif;

echo $kirby->render();
5 Likes