Created
May 16, 2018 04:09
-
-
Save firasd/7e09c287530a1dafd19690fdc9e6e167 to your computer and use it in GitHub Desktop.
Redirect WordPress user from LearnDash course page to first lesson page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment