User roles and permission linked to personal sub-page

permissions

#1

Im creating a site for a creative workspace where all the residents will have there own subpage. Which will show some of their work, exhibition events, bio etc. And im trying to figure out if its possible to have roles that are linked to specific pages. An account page Id linked to a Role id?

Like Person A can update his own portfolio and add some news articles on the homepage. But is not able to go into/or edit the page of Person B.

Thanks in Advance!


#2

Yes, that can. be achieved using permissions

https://getkirby.com/docs/panel/permissions


#3

Cool thanks!
And is it also possible to create a new user and automatically a new member page will be created?
Super new in this so dont know what to search.


#4

Yes, this can be done with a user.create hook

https://getkirby.com/docs/developer-guide/advanced/hooks


#7

i cant seem to link it to a username. Is this the right direction?

'panel.page.update' => function() { 
  return $this->target()->page()->title() = $this->username();
}

?
thanks in advance


#8

Not quite.

First of all, if you want to compare values, you have to use a comparison operator, not an assignment operator.

Secondly, you have to get the user before you can call the username.

And last, this will only work if the title is exactly the same as the username; you might want to compare to the uid instead of the title.

This could work, though not tested:

'panel.page.update' => function() { 
  return $this->target()->page()->title() == $this->user()->username();
}

By the way, you can always edit your posts and don’t have to create new ones. Also, please always wrap code within three backticks on a separate line before and after your code block. Thank you.