function course_uc_course_enrollment_insert in Course 8.2
Same name and namespace in other branches
- 8.3 modules/course_uc/course_uc.module \course_uc_course_enrollment_insert()
- 7.2 modules/course_uc/course_uc.module \course_uc_course_enrollment_insert()
- 7 modules/course_uc/course_uc.module \course_uc_course_enrollment_insert()
- 3.x modules/course_uc/course_uc.module \course_uc_course_enrollment_insert()
Implements hook_course_enroll().
Satisfy payment requirement when manually enrolled.
File
- modules/
course_uc/ course_uc.module, line 202
Code
function course_uc_course_enrollment_insert($enrollment) {
$node = \Drupal\node\Entity\Node::load($enrollment->nid);
$user = Drupal\user\Entity\User::load($enrollment->uid);
$course = course_get_course($node);
if (course_uc_payment_is_first($course)) {
foreach ($course
->getObjects() as $courseObject) {
$courseObject
->getFulfillment($user)
->setComplete(TRUE)
->save();
break;
}
}
}