Override User Blueprint in Plugin

Hi Community!

I was successfully able to override page blueprints based on the role by following this guide here:

BUT it doesn’t work when I try to override a user blueprint:

kirby::plugin('cookbook/role-blueprints', [
    'blueprints' => [
        'pages/test' => $dirtest, // path to yaml --> WORKS
        'users/editor' => $diruser // path to yaml --> DOESN'T WORK
    ]
]);

When I do it like in the example, all users are displayed as “nobody”, because kirby can’t read the role anymore. Am I missing something? Is the path wrong or doesn’t it work for roles at all?

That should work, what does $diruser point to and what’s inside that file? Maybe you have an error somewhere.

i have the same problem but with php file.

kirby::plugin('user_name/package_name', [
    'blueprints' => [
        'users/member' => function () {
            return include __DIR__ . '/blueprints/users/member.php';
        },
    ],
    // I tried this too
    'hooks' => [
        'user.create:after' => function (User $user) {
            $user->changeRole('member');
        }
    ]
]);

member.php:

return [
    'title' => 'Mitglied',
    'name' =>' member',
    'description' => 'Hier fehlt noch die Beschreibung',
    'permissions' => [
        'access' => [
            'panel' => false
        ]
    ],
    'columns' => [
        'top'=> [
            'width' => '1/1',
            'fields' => [
                'firstname' => [
                    'type' => 'text',
                    'label' => 'Vorname',
                    'required' => true
                ],
                'lastname' => [
                    'type' => 'text',
                    'label' => 'Nachname',
                    'required' => true
                ]
            ]
        ],
        'left' => [
            'width' => '1/2',
            'fields' => [
                'street' => [
                    'label' => 'Straße und Hausnummer',
                    'type' => 'text'
                ],
                'zip' => [
                    'label' => 'Postleitzahl',
                    'type' => 'text',
                    'width' => '1/4'
                ],
                'city' => [
                    'label' => 'Stadt/Ort',
                    'type' => 'text',
                    'width' => '3/4'
                ],
                'country' => [
                    'label' => 'Land',
                    'type' => 'text'
                ]
            ]
        ],
        'middle' => [
            'width' => '1/2',
            'fields' => [
                'email' => [
                    'label' => 'E-Mail',
                    'type' => 'email'
                ],
                'phone' => [
                    'label' => 'Telefon',
                    'type' => 'tel',
                    'icon' => 'phone',
                    'placeholder' => '+49'
                ],
                'mobilePhone' => [
                    'label' => 'Telefon (mobil)',
                    'type' => 'tel',
                    'icon' => 'phone',
                    'placeholder' => '+49'
                ],
                'birthday' => [
                    'label' => 'Geburtsdatum',
                    'type' => 'date',
                    'display' => 'DD.MM.YYYY'
                ]
            ]
        ],
        'right' => [
            'width' => '1/3',
            'fields' => [
                'rolle' => [
                    'label' => 'Rolle',
                    'type' => 'select',
                    'options' => UserMemberPage::rollen()
                ],
                'funktion' => [
                    'label' => 'Funktion/Position',
                    'type' => 'select',
                    'options' => UserMemberPage::positionen()
                ]
            ]
        ]
    ]
];

The user is created but with the role “nobody”. If I then manually change the role to “member” then my PHP based blueprint also works.

solved