function _user_resource_cancel in Services 7.3
Cancel a user.
Parameters
$uid: UID of the user to be canceled.
See also
1 string reference to '_user_resource_cancel'
- _user_resource_definition in resources/
user_resource.inc
File
- resources/
user_resource.inc, line 560
Code
function _user_resource_cancel($uid) {
if ($uid == 1) {
return services_error(t('The admin user cannot be canceled.'), 403);
}
$account = user_load($uid);
if (empty($account)) {
return services_error(t('There is no user with ID @uid.', array(
'@uid' => $uid,
)), 404);
}
$edit = array(
'user_cancel_notify' => isset($account->data['user_cancel_notify']) ? $account->data['user_cancel_notify'] : variable_get('user_mail_status_canceled_notify', FALSE),
);
// This defult setting is defined under "admin/config/people/accounts".
$default_method = variable_get('user_cancel_method', 'user_cancel_block');
// Modules use hook_user_delete() to respond to deletion.
if ($default_method != 'user_cancel_delete') {
// Allow modules to add further sets to this batch.
module_invoke_all('user_cancel', $edit, $account, $default_method);
}
_user_cancel($edit, $account, $default_method);
// Everything went right.
return TRUE;
}