Skip to content

Commit

Permalink
Change the restriction message to the enrollment drip message, since …
Browse files Browse the repository at this point in the history
…lessons wouldn't necessarily be available on the course start date if there's the enrollment drip setting in place.
  • Loading branch information
brianhogg committed Jan 6, 2025
1 parent 5ac50fe commit b118bae
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions includes/functions/llms.functions.access.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ 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;

// 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;
}
$lesson = new LLMS_Lesson( $post_id );

$lesson_id = llms_is_post_restricted_by_drip_settings( $post_id, $user_id );
if ( $lesson_id && 'enrollment' === $lesson->get( 'drip_method' ) ) {
$results['is_restricted'] = true;
$results['reason'] = 'lesson_drip';
$results['restriction_id'] = $lesson_id;
/* This filter is documented above. */
return apply_filters( 'llms_page_restricted', $results, $post_id );
}

if ( $results['is_restricted'] ) {
if ( ! $lesson_id && 'enrollment' !== $lesson->get( 'drip_method' ) ) {
$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 );
}
Expand Down

0 comments on commit b118bae

Please sign in to comment.