Hello,
Can we call the current user id in a blueprint?
Something like:
page.drafts.filterBy('evaluatorId', kirby.user.id)
I tried but didn’t seem to work.
Hello,
Can we call the current user id in a blueprint?
Something like:
page.drafts.filterBy('evaluatorId', kirby.user.id)
I tried but didn’t seem to work.
What version are you trying this with?
The last one K 3.2.2
I would think this should work… do you get any error message?
@gillesvauvarin Could you post some context where you are using this query, please?
I use the plugin “page display section” to select “evaluation” pages with a query.
These pages have an hidden field called “evaluatorId” to store the ids of certain evaluators user.
When an evaluator log in to the panel, I want to display only the evaluation pages which own the “evaluatorId” so I use this query:
page.drafts.filterBy('evaluatorId', kirby.user.id, ',')
Here “page.” is a “proposal” page and "drafts."are “evaluation” page.
Looks like fetching the current user doesn’t work for some reason. If you hardcode a value, it works, I guess?
Yes it works if I hardcode the user id
page.drafts.filterBy('evaluatorId', 'kgesqYt', ',')
else
page.drafts.filterBy('evaluatorId', kirby.user.id, ',')
just return nothing without error message.
I found another solution by using a page model to override the “Drafts” function but I didn’t find why kirby.user.id seems not return the current user id :-/
I don’t know, you also can’t get the current page, I think, while you can get the current language. Maybe a bug. Would you create an issue on GitHub?
Yes I will do it