You are here

function course_user_delete in Course 3.x

Same name and namespace in other branches
  1. 8.3 course.module \course_user_delete()
  2. 8.2 course.module \course_user_delete()
  3. 7.2 course.module \course_user_delete()
  4. 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();
  }
}