Jump to content
pwfans

Page reference field for user roles permission problem

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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 🙂

  • Like 2

Share this post


Link to post
Share on other sites

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;
});

 

  • Sad 1

Share this post


Link to post
Share on other sites

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 !

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...