bernhard

Cannot select users in page field

Recommended Posts

Hey!

I have a strange problem with a pagefield. As SuperUser everything works fine, but as "admin" I cannot select the "client" for a "training":

NIiRrNe.png

The field is set to this:

IEVQrUR.png

And the label field is "fullname". As SuperUser it just works fine:

N9B8IIs.png

And the search also works (as admin):

8PzTx6L.png

Any ideas?

Share this post


Link to post
Share on other sites

You need to add "check_access=0" to the selector.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

You will also come up agains this: https://github.com/processwire/processwire-issues/issues/550

This will fix that issue:

$this->addHookBefore('Pages::find', function(HookEvent $event) {
    $selector = $event->arguments(0);
    if(is_string($selector) && strpos($selector, 'template=user') !== false && strpos($selector, 'name|first_name|last_name%=') !== false) {
        $selector .= ', check_access=0';
    }
    $event->arguments(0, $selector);
});

PS - you might need to adjust the modified selector to suit your needs - re the first_name, last_name etc

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites

Alternatively you can hook after ProcessPageSearch::findReady to make it a bit more specific to autocomplete:

 

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites
3 hours ago, Robin S said:

Alternatively you can hook after ProcessPageSearch::findReady to make it a bit more specific to autocomplete:

Thanks @Robin S - you just reminded me to update to that version - cheers!

  • Like 1

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.