function uc_file_remove_user in Ubercart 8.4
Same name and namespace in other branches
- 6.2 uc_file/uc_file.module \uc_file_remove_user()
- 7.3 uc_file/uc_file.module \uc_file_remove_user()
Removes all of a user's downloadable files.
Parameters
$uid: A Drupal user ID.
1 call to uc_file_remove_user()
- uc_file_user_cancel in uc_file/
uc_file.module - Implements hook_user_cancel().
File
- uc_file/
uc_file.module, line 709 - Allows products to be associated with downloadable files.
Code
function uc_file_remove_user($user) {
$connection = \Drupal::database();
$query = $connection
->delete('uc_file_users')
->condition('uid', $user
->id());
// Echo the deletion only if something was actually deleted.
if ($query
->execute()) {
$userlink = [
'#theme' => 'username',
'#account' => $user,
];
\Drupal::messenger()
->addMessage(t('@user has had all of his/her downloadable files removed.', [
'@user' => drupal_render($userlink),
]));
}
}