pwfans Posted April 4, 2020 Share Posted April 4, 2020 Using page reference field to get some users under certain role: - At input tab, i select "Custom find" to query users under certain roles. Problem is: for user_1 which is not superuser, above field doesn't work, page reference content not displayed. However if i give superuser role to user_1, above field work like expected which of course, i don't want to give superuser role to user_1. I already tried check all permissions available to user_1 and add custom predefined system permissions (user-admin-all, user-admin-[role]), still doesn't work. Link to comment Share on other sites More sharing options...
teppo Posted April 4, 2020 Share Posted April 4, 2020 In case you're using Page Autocomplete for the inputfield, this might be related: https://github.com/processwire/processwire-issues/issues/550. Either way, you'll likely have to switch from "custom find" to "selector string" and include "check_access=0" in your selector to get this working ? 2 Link to comment Share on other sites More sharing options...
adrian Posted April 4, 2020 Share Posted April 4, 2020 Frustrating that we are still dealing with this 2 years later, but this is what I am currently using (thanks to @Robin S? // hack to overcome this: https://github.com/processwire/processwire-issues/issues/550 // from: https://processwire.com/talk/topic/19913-solved-page-reference-field-unpublished-pages-not-visible-by-non-superuser-rolesusers/?do=findComment&comment=172593 $this->wire()->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) { $selector = $event->arguments(0); if(strpos($selector, 'template=user') !== false && strpos($selector, 'name|first_name|last_name%=') !== false) { $selector .= ', check_access=0'; } $event->return = $selector; }); 1 Link to comment Share on other sites More sharing options...
pwfans Posted April 6, 2020 Author Share Posted April 6, 2020 Thanks a lot @teppo and @adrian I ended up with @teppo's way using selector string, and using check_access=0 (just knew this) works like expected ! Link to comment Share on other sites More sharing options...
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