Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save j2machado/481ee544b01f0f1efed807003cf658a9 to your computer and use it in GitHub Desktop.

Select an option

Save j2machado/481ee544b01f0f1efed807003cf658a9 to your computer and use it in GitHub Desktop.
LearnDash LMS - Bypass the linear progression for courses.
<?php
/**
* Bypass the linear progression for courses in LearnDash LMS,
* leveraging the learndash_course_progression_enabled filter.
*
* @param bool $setting. The $setting value in the database. True for Linear Progression, False for Free Form.
* @param int $course_id. The course ID.
*
* @return bool.
*/
// Bypass linear progression for a single defined course.
add_filter('learndash_course_progression_enabled', function($setting, $course_id){
return (3998 === $course_id) ? false : $setting;
}, 10, 2);
// Bypass linear progression for multiple specific courses.
add_filter('learndash_course_progression_enabled', function($setting, $course_id){
$excluded_course_ids = array(3998, 4000, 4002, 4005); // Array of course IDs to exclude
return in_array($course_id, $excluded_course_ids) ? false : $setting;
}, 10, 2);
// Bypass linear progression for all courses with no exceptions.
add_filter('learndash_course_progression_enabled', '__return_false');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment