Skip to content

Commit

Permalink
If the lesson would be restricted by the course start date, but the l…
Browse files Browse the repository at this point in the history
…esson has "# days after enrollment" drip settings, use that restriction instead.
  • Loading branch information
brianhogg committed Jan 6, 2025
1 parent 7bcb252 commit 5ac50fe
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions includes/functions/llms.functions.access.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,24 @@ function llms_page_restricted( $post_id, $user_id = null ) {

$course_id = llms_is_post_restricted_by_time_period( $post_id, $user_id );
if ( $course_id ) {

$results['is_restricted'] = true;
$results['reason'] = 'course_time_period';
$results['restriction_id'] = $course_id;
/* This filter is documented above. */
return apply_filters( 'llms_page_restricted', $results, $post_id );

// If this post id is a lesson and has drip settings by enrollment date, still allow it.
if ( ! llms_is_post_restricted_by_drip_settings( $post_id, $user_id ) ) {
$lesson = new LLMS_Lesson( $post_id );
if ( 'enrollment' === $lesson->get( 'drip_method' ) ) {
$results['is_restricted'] = false;
$results['reason'] = 'accessible';
$results['restriction_id'] = 0;
}
}

if ( $results['is_restricted'] ) {
/* This filter is documented above. */
return apply_filters( 'llms_page_restricted', $results, $post_id );
}
}

$prereq_data = llms_is_post_restricted_by_prerequisite( $post_id, $user_id );
Expand Down

0 comments on commit 5ac50fe

Please sign in to comment.