bernhard Posted February 7, 2019 Share Posted February 7, 2019 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": The field is set to this: And the label field is "fullname". As SuperUser it just works fine: And the search also works (as admin): Any ideas? Link to comment Share on other sites More sharing options...
adrian Posted February 7, 2019 Share Posted February 7, 2019 You need to add "check_access=0" to the selector. 2 2 Link to comment Share on other sites More sharing options...
adrian Posted February 7, 2019 Share Posted February 7, 2019 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 5 1 Link to comment Share on other sites More sharing options...
bernhard Posted February 7, 2019 Author Share Posted February 7, 2019 Thank you very much adrian! 2 Link to comment Share on other sites More sharing options...
Robin S Posted February 7, 2019 Share Posted February 7, 2019 Alternatively you can hook after ProcessPageSearch::findReady to make it a bit more specific to autocomplete: 4 1 Link to comment Share on other sites More sharing options...
adrian Posted February 8, 2019 Share Posted February 8, 2019 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! 1 Link to comment Share on other sites More sharing options...
rick Posted March 9, 2022 Share Posted March 9, 2022 This is still an issue. I cannot select a user from an auto complete select on an admin form. Even with the hooks @adrian and @bernhardsuggested in this reported issue. My select field is configured as follows:Page field value type = single/false (other options make no difference). Allow unpublished pages = checked. Type: Page auto complete. Template = User. Selector string = template=user, include=all, check_access=0, sort=name. Label field = name. When attempting to edit a page with this field this is the resulting selector: template=user, sort=title, templates_id=3, title%=sca, limit=50 *Notice the duplicate template reference. This obviously is a core issue. The resulting query is: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_title AS field_title ON field_title.pages_id=pages.id AND (((field_title.data LIKE '%sca%' ) )) LEFT JOIN field_title AS _sort_title ON _sort_title.pages_id=pages.id WHERE (pages.templates_id=3) AND (pages.templates_id=3) GROUP BY pages.id ORDER BY _sort_title.data LIMIT 0,50 Two issues with this query; 1) there are no user names present in the field_title.data column, 2) the join statement has three levels of parens, which are obviously leftover from from whatever concatenation function that was previously performed. This again is a core issue. All of my projects rely on selecting a user at various steps. Can anyone provide a workaround, or tell me what I have done wrong? I appreciate your input. Link to comment Share on other sites More sharing options...
adrian Posted March 9, 2022 Share Posted March 9, 2022 @rick - did you try Robin's version: https://processwire.com/talk/topic/19913-solved-page-reference-field-unpublished-pages-not-visible-by-non-superuser-rolesusers/?do=findComment&comment=172578 That's what I've been using for a long time now. 1 Link to comment Share on other sites More sharing options...
rick Posted March 9, 2022 Share Posted March 9, 2022 Thank you @adrian, I did not see that. I appreciate you locating that topic. I have it saved for future reference. In the meantime I came up with a workaround where I don't have to modify a user's ready.php file during install. 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