diff --git a/.changelogs/allow-lesson-access-based-on--enrollment-drip-setting.yml b/.changelogs/allow-lesson-access-based-on--enrollment-drip-setting.yml new file mode 100644 index 0000000000..c820955a95 --- /dev/null +++ b/.changelogs/allow-lesson-access-based-on--enrollment-drip-setting.yml @@ -0,0 +1,6 @@ +significance: patch +type: changed +links: + - "#2843" +entry: Allow lesson access based on enrollment drip setting with Course Start + Date set. diff --git a/includes/functions/llms.functions.access.php b/includes/functions/llms.functions.access.php index fe1381eb84..1196bc6c85 100644 --- a/includes/functions/llms.functions.access.php +++ b/includes/functions/llms.functions.access.php @@ -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 ) { + $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 ); + } - $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 ( ! $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 ); + } } $prereq_data = llms_is_post_restricted_by_prerequisite( $post_id, $user_id );