I'm trying to use the following drush script, but I keep getting errors. Currently, it is not properly setting the user role to Premium.
#!/user/bin/env drush
<?php
$users = [
"name" => "email",
"name" => "email",
"name" => "email",
"name" => "email",
"name" => "email",
"name" => "email",
"name" => "email",
"name" => "email",
];
foreach ($users as $key => $val) {
drush_invoke("user-create", $val);
drush_print("Created account for email " . $val);
drush_set_option("password", $key);
drush_invoke('user-password', $val);
drush_print("Created password for email " . $val . " with password " . $key);
drush_set_option("mail", $val);
drush_invoke('user-add-role', "Premium members");
drush_print("Added premium role to " . $val);
}
?>
Is there a better way to achieve this?
role-create
)? Probably you've to pass extra argument foruser-add-role
command to specify the username ($key
).