Jump to content

Page reference field for user roles permission problem


pwfans
 Share

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.

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...