function course_uc_course_can_enrol in Course 6
Implements hook_course_can_enrol().
Can the user self-enrol in this course? No, they have to pay for it.
File
- modules/
course_uc/ course_uc.module, line 387
Code
function course_uc_course_can_enrol($node, $user) {
$course = course_get_course($node, $user);
foreach ($course
->getObjects() as $idx => $courseObject) {
if ($idx == 0) {
// Completely block access if it is the first object.
if ($courseObject
->getComponent() == 'payment' && !$courseObject
->getFulfillment()
->isComplete()) {
return array(
'course_must_purchase' => array(
'success' => FALSE,
'message' => 'You must first purchase this course.',
),
);
}
}
}
}