How to Redirect LearnDash User From Course Page to First Lesson Page

How to Redirect LearnDash User From Course Page to First Lesson Page
You can redirect people automatically to the first lesson of the course after they select a course, skipping the list of lessons page. It is possible by using a custom code insertion in your theme's main function.php page.Once a user joins a course, if you want him to redirect to the first lesson of the course he joined, add following a code in your theme function.php file [This code is courtesy Firas Durri https://gist.github.com/firasd/7e09c287530a1dafd19690fdc9e6e167]
<?php

add_action('template_redirect', function () {
	if (is_user_logged_in()) {
		$q_object = get_queried_object();
		if (($q_object) && (is_a($q_object, 'WP_Post')) && ($q_object->post_type == 'sfwd-courses')) {
			if (sfwd_lms_has_access($q_object->ID)) {
				$steps = learndash_get_course_steps($q_object->ID);
				if (count($steps)) {
					wp_redirect(get_permalink($steps[0]));
					die();
				}
			}
		}
	}
}

, 1);

?>
Since this is a custom code for a specific purpose within LearnDash, you must comment outif for any reason, you disable LearnDash, you must comment out the code ..