I’d like to post an entry/note and then only allow it to be edited by low level users for a certain period of time, something like 2 weeks and then restrict editing to higher level users. It would be preferable to have this automated, but I don’t know how doable this is.
Is this an unusual goal or something relatively easy to implement?
I tried to delete this to post a different but related/easier question:
As a different approach to the above, I’d like to instead just restrict a certain role to only seeing the latest published post in the panel. In the panel section for that role I have:
type: pages
label: Personal Photo Challenges
parent: kirby.page("ppc")
size: large
info: "{{ page.images.count }} image(s)"
layout: cards
template: prompt
sortable: false
flip: false
status: published
max: 1
empty: No prompts yet
image:
query: page.cover
cover: true
ratio: 5/4
The “max” value does not limit to one page though. Not sure what I’m doing wrong there-
What you could do instead is overwrite the isReadable()
page method in a page model. That way you can check for both date and role and set the return value to false
as needed.
Ok this sounds like a next-level thing for me but I will research and see if I can figure it out. I have another question that may not warrant starting a whole separate topic:
The user who attaches a file does not get stored somewhere does it? If I wanted to pull a name from an image based on the user who uploaded it, that would require some sort of plugin?
You could achieve that with a file.upload:after hook, that stores the current user who uploads the image in the file meta data.
Thank you I’ll look into how to achieve that-
Ok I think I’m almost there with the username hook, but my lack of knowledge with kirby/php has me missing one last piece. This code works except it inputs the user ID (the unreadable name):
'hooks' => [
'file.create:after' => function ($file, $user) {
$user = kirby()->user();
$file->update([
'Photographer' => $user
]);
}
]
What should user()
be to show the username?
Edit I found it! Just needed to add ->username()
afterward. Ok now to tackle that earlier isReadable()
issue.
I wouldn’t use the username but the $user->id()
, as the name may not be unique
Thank you-