Jump to content

Permit access to repeater field pages


MarkE
 Share

Recommended Posts

I have a number of pages which host dependent select fields. The contents of these are drawn from various repeater fields (actually repeaterMatrix, but I don't think that's relevant to the problem) - i.e. they are provided by a selector which is something like "template=repeater_field_name, ...". They all work fine in superuser, but in any non-superuser role, they return an empty result, even if the role has the maximum permissions. It seems like every repeater template needs to specifically permit access to the required roles, because they are all children of 'admin'.

Is this so? Is there a shortcut way of doing this (there are a lot of such fields)?

Edit: I guess what I would like to do is to set the access to the repeater page to be the same its host page (getForPage) rather than admin. Any ideas?

Link to comment
Share on other sites

Hello @MarkE,

I think you need to add "include=all" or "check_access=0" to the selector of your select options field for other user roles: https://processwire.com/docs/selectors/#access_control

$pages->find("template=repeater_field, include=all");

Because as you already mentioned repeater pages are children of the Admin tree which other user roles cannot find.

Regards, Andreas

Link to comment
Share on other sites

Thanks @AndZyk. I had tried check_access, but it didn't work. I found out why - because ProcessPageSearch contains the following:

			// don't allow setting of check_access property, except for superuser
			if($lowerName == 'check_access' && !$superuser) continue; 

So I sort-of hacked it with a hook:

wire()->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) {
	$selector = $event->return;
	$user = wire()->users->getCurrentUser();
	if($user->hasRole('webmaster')) $selector = 'check_access=0, ' . $selector;
	$event->return = $selector;
});

which works, but I'm not very happy with it!

  • Like 1
Link to comment
Share on other sites

Thanks @AndZyk. I am using dependent selects. So it needs check_access=0 in the input tab as you suggest for InputfieldPage to get it. However for dependent selects, ProcessPageSearch is called to populate the options and strips out the 'check_access'. Then, when the options don't include the already-selected item provided by InputfieldPage, it is removed ?

I think perhaps I should raise this as an issue or feature request.

  • Like 2
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...