function cas_drush_user_create in CAS 7
Same name and namespace in other branches
- 6.3 cas.drush.inc \cas_drush_user_create()
Creates a new CAS user account.
1 string reference to 'cas_drush_user_create'
- cas_drush_command in ./
cas.drush.inc - Implements hook_drush_command().
File
- ./
cas.drush.inc, line 61 - Drush commands for CAS.
Code
function cas_drush_user_create($cas_name) {
// @todo: Handle additional options for setting other user attributes.
$account = cas_user_load_by_name($cas_name);
if ($account === FALSE) {
if (!drush_get_context('DRUSH_SIMULATE')) {
$options = array(
'invoke_cas_user_presave' => TRUE,
);
$new_user_object = cas_user_register($cas_name, $options);
if ($new_user_object !== FALSE) {
$user_fields = array(
'cas_name',
'uid',
'name',
'mail',
'status',
);
$new_user_object = (array) $new_user_object;
$new_user_object = array_intersect_key($new_user_object, array_flip($user_fields));
$new_user_object = drush_key_value_to_array_table($new_user_object);
drush_print_table($new_user_object);
}
else {
drush_set_error(dt('Could not create a new user account with CAS username @cas_name.', array(
'@cas_name' => $cas_name,
)));
}
}
}
else {
drush_set_error(dt('There is already a user account with CAS username @cas_name.', array(
'@cas_name' => $cas_name,
)));
}
}