processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Users cannot have users as children, the $users->find doesnt seem to work

Open cb2004 opened this issue 5 years ago • 3 comments

Using ProcessWire 3.0.164 I am a big user of:

https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users

The issue I have is for numerous sites they have paid subscriptions, the main user is under a parent 'Members' and holds all the organisation data. The organisation want sub-members to have access to the system. Following the guidelines above, it doesnt work as you have to set a parent for the users in config.php (guessing why this doesnt work), obviously everybody under 'Members' would be a parent. Everything seems to work ok in the backend, I just cant $users->find, $users->get("email=address") to log them in etc.

cb2004 avatar Aug 03 '20 21:08 cb2004

I have this working with a normal template which is fine, but I am using roles to allow file downloading etc so really need this to work.

cb2004 avatar Aug 03 '20 21:08 cb2004

Looks like this would achieve what I need but seems overkill:

https://processwire.com/talk/topic/9034-regarding-config-userspageids-of-new-user-templates-in-2514-the-right-hook/

cb2004 avatar Aug 03 '20 22:08 cb2004

In the end I went with a solution in ready.php:

$members = wire('pages')->get(1302)->children;
$subMembers = array();
foreach($members as $m) $subMembers[] = $m->id;

And in config.php:

$config->usersPageIDs = array_merge($config->usersPageIDs, $subMembers);

Seems to be working ok, but would you consider revisiting this functionality?

cb2004 avatar Aug 04 '20 08:08 cb2004