function course_user_delete in Course 3.x
Same name and namespace in other branches
- 8.3 course.module \course_user_delete()
- 8.2 course.module \course_user_delete()
- 7.2 course.module \course_user_delete()
- 7 course.module \course_user_delete()
Implements hook_user_delete().
Clean up course reports and fulfillments for a deleted user.
File
- ./
course.module, line 697 - course.module Core functionality for Courses.
Code
function course_user_delete(AccountInterface $account) {
$enrollments = Drupal::entityTypeManager()
->getStorage('course_enrollment')
->loadByProperties([
'uid' => $account
->id(),
]);
foreach ($enrollments as $enrollment) {
$enrollment
->delete();
}
}