Different site blueprint depending on user

I have had a look at the cookbook and through here to try and work out how to get a different site.yml to display depending on user role, but haven’t managed to get it working.

I have a user role of mentor, for which I need to show a different site.yml blueprint. I have added this in plugins/role-blueprints/index.php:


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

Kirby::plugin('role-blueprints/permissions', [
    'blueprints' => [
        'site' => $dir

And added a new simple site.yml in site/blueprints/mentor/site.yml. However when I log in I can still see the standard site.yml which should only be visible to admin users.

I am not sure where I am going wrong, if anyone has any insight that would be super.

Have you removed the site.yml from /site/blueprints?

No… I didn’t realise I needed to do that.
When I have removed it what will be used for admin users logging in?

The one defined in your else statement above, as that will be the one used by all users but those with role mentor. Have you added it in the path given in your plugin?

Ah ok I didn’t realise I needed to add both the mentor blueprint and the general blueprint to my plugin folder, and remove the site/blueprints/site.yml as well. I have done this now and it looks like it is working properly.

Big thanks for your help as always

I thought the instructions were pretty clear, you prove me wrong :wink: What should have been explained better? That __DIR__ refers to the current directory?

Yes, that was the part that was tripping me up I assumed it was referring to the site directory. This is the cookbook article section I was looking at - Going beyond Kirby's permissions features | Kirby CMS, and it wasn’t clear I needed to create my own blueprints directory.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
– Douglas Adams

ok, will make a note to improve that