Skip to content

Missing Guest Role (API created users) #203

@suntrop

Description

@suntrop

Short description of the issue

Missing guest role when adding user via API

Expected behavior

Since guest is required (?) it should be added by default

Actual behavior

New user only gets the role I specify

Steps to reproduce the issue

I noticed the users I add via the API, are missing the "guest" role. I don't know if the missing role is somewhat preblematic, but if it is required by the system, I think it should be added by default.

$u = new User();
$u->of(false);
$u->name = $email;
$u->pass = $password;
$u->addRole('customer');
$u->email = $email;

// User details
$u->user_name->first_name = $first_name;
$u->user_name->last_name = $last_name;

// User details
$new_addressbook_entry = $u->user_addressbook->makeBlankItem();
$new_addressbook_entry->first_name = $first_name;
$new_addressbook_entry->last_name = $last_name;
$u->user_addressbook->add($new_addressbook_entry);

// User Hash
$u->user_hash = md5(uniqid($email, true));

$u->save();

Setup/Environment

  • ProcessWire version: 3.0.42
  • (Optional) PHP version: 7
  • (Optional) MySQL version: 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions