Drupal 8: How to create user with role programatically

Drupal 8: How to create user with role programatically




$values = array(
'field_first_name' => 'test',
'fieldt_last_name' => 'g',
'name' => 'test123',
'mail' => 'test@test.com',
'roles' => array('administrator'),
'pass' => 'password',
'status' => 1,
);
$account = entity_create('user', $values);
$account->save();

Comments

Post a Comment

Popular Posts