MarkE Posted September 4, 2022 Posted September 4, 2022 I have a number of pages which host dependent select fields. The contents of these are drawn from various repeater fields (actually repeaterMatrix, but I don't think that's relevant to the problem) - i.e. they are provided by a selector which is something like "template=repeater_field_name, ...". They all work fine in superuser, but in any non-superuser role, they return an empty result, even if the role has the maximum permissions. It seems like every repeater template needs to specifically permit access to the required roles, because they are all children of 'admin'. Is this so? Is there a shortcut way of doing this (there are a lot of such fields)? Edit: I guess what I would like to do is to set the access to the repeater page to be the same its host page (getForPage) rather than admin. Any ideas?
AndZyk Posted September 5, 2022 Posted September 5, 2022 Hello @MarkE, I think you need to add "include=all" or "check_access=0" to the selector of your select options field for other user roles: https://processwire.com/docs/selectors/#access_control $pages->find("template=repeater_field, include=all"); Because as you already mentioned repeater pages are children of the Admin tree which other user roles cannot find. Regards, Andreas
MarkE Posted September 5, 2022 Author Posted September 5, 2022 Thanks @AndZyk. I had tried check_access, but it didn't work. I found out why - because ProcessPageSearch contains the following: // don't allow setting of check_access property, except for superuser if($lowerName == 'check_access' && !$superuser) continue; So I sort-of hacked it with a hook: wire()->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) { $selector = $event->return; $user = wire()->users->getCurrentUser(); if($user->hasRole('webmaster')) $selector = 'check_access=0, ' . $selector; $event->return = $selector; }); which works, but I'm not very happy with it! 1
AndZyk Posted September 6, 2022 Posted September 6, 2022 I was referring to the selector string options of a page field under the input tab. If your case is more complicated than that, sorry I don't think I can help you. ? 1
MarkE Posted September 6, 2022 Author Posted September 6, 2022 Thanks @AndZyk. I am using dependent selects. So it needs check_access=0 in the input tab as you suggest for InputfieldPage to get it. However for dependent selects, ProcessPageSearch is called to populate the options and strips out the 'check_access'. Then, when the options don't include the already-selected item provided by InputfieldPage, it is removed ? I think perhaps I should raise this as an issue or feature request. 2
MarkE Posted September 7, 2022 Author Posted September 7, 2022 On 9/6/2022 at 11:16 AM, MarkE said: I think perhaps I should raise this as an issue or feature request Actually, I am building a little module to fix it, hopefully ? -Edit: You can now find it here. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now