Jump to content

User guest role


alejandro
 Share

Recommended Posts

Hello,

when creating a new user via API without assining the role 'guest' it seems PW assigns it by default. But it doesn´t appear in the user list roles column. Although is seems to be assigned anyway when displaying the user page.

Update: the guest role appears when the user is assigned another role in de admin. 

1) Should I assign the guest role when creating the user with the API? (I guess it´s not necessary)

2) Is there, anyway, an API syntax to assign 2 roles at a time?:

$u->addRole("guest, customer")  (doesn´twork)
--------------------------------------
$u->addRole("guest"); 
$u->addRole("customer";)   it works but a bit repetitive

Thanks.

Link to comment
Share on other sites

What about:

foreach(array('guest', 'customer') as $r) $u->addRole($r);

Still, I don't see any reason to add the guest role manually, so if you are only adding one other additional role, then you probably don't need anything to reduce multiple lines.

It seems like maybe something changed recently. What version of PW are you running? If I test on 2.4.5 the guest role is automatically added, but not in 2.4.11 - https://github.com/ryancramerdesign/ProcessWire/issues/588

Wow - I am having a rough morning - nothing has changed - behavior seems to be consistent through versions.

Edited by adrian
  • Like 1
Link to comment
Share on other sites

2.4.10

But the guest role is indeed added, just it doesn´t appear under the column roles in the user list. So, at first I had the doubt if it was necessary to add it via API.

I don't think it is actually added though - if you look at the field_roles database table and look for entry with a pages_id that matches the user, there won't be one. There should be one with a data: 37 (page id of the guest role).

When you view the user page, there is some logic that ensures the guest role checkbox is checked, but it's not being stored in the database. 

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...