Change Permissions for logged out users

I was wondering if there is a possiblilty to change the permissions of a not logged in user who is just browsing the Frontend of my Website I found this in the Documentation: https://getkirby.com/docs/guide/users/permissions

From my understanding this only comes into affect when a user is acually logged in.
Even the “Visitor” Section would need a user blueprint and then the visitor would still have to login through some kind of form.

I wanted to create a form which then creates a Page in my Backend but since a not loggin in user does not have permissions to create I was wondering about this.

If you want to allow visitors (who are not users) to do something like creating a page, you can use the $kirby->impersonate() method, either with the Kirby almighty user or with an existing user who has the relevant permissions.

https://getkirby.com/docs/guide/users/permissions#authenticate-or-impersonate

1 Like

Thank you for your quick help!

I have just created a new user called “Frontend” .

This is my blueprint

title: Frontend
permissions:
  access:
    panel: false
    create: true

And this is the created user:

return array (
'email' => 'frontend@xxx-xxx.de',
'language' => 'en',
'name' => 'Frontend',
'role' => 'frontend',
);

But when trying to impersonate the user “Frontend”
By doing this:

$kirby = kirby();
$kirby->impersonate('Frontend');

I always get the following Error:

The user "Frontend" cannot be found

On the documentation is says that for $who I can just use the kirby superuser, a username or null to reset the impersination. How come I still get this error though`?

You created a user role, not a user. A blueprint only defines a possible user role. If you want to use a user with that role, you have to create a user with that role first.

Also, there is no create property in the access section…

But the User is also listed in the “accounts” folder.
In the Kirby Backend I can also see the “Frontend” user when navigating to “http://website.test/panel/users

Oh, alright. I think you have to pass the email of the user as argument.

Great. Now it works as expected. Thanks!
Mabye the documentation should be updated then because it states you have to pass the username as the argument.
https://getkirby.com/docs/reference/objects/kirby/impersonate