Skip to content

Instantly share code, notes, and snippets.

@BoyetDgte
Created March 25, 2021 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BoyetDgte/5e4a7aa2ae9efcf89bdfecf569735cd0 to your computer and use it in GitHub Desktop.
Save BoyetDgte/5e4a7aa2ae9efcf89bdfecf569735cd0 to your computer and use it in GitHub Desktop.
Redirect to any page after LearnDash course is completed
add_action('learndash_course_completed', 'course_completed', 10, 1);
function course_completed( $data ) {
$course_id = $data['course']->ID;
$slug_url = get_post_field( 'post_name', $course_id );
if ($course_id) {
// After creating a "congrats" parent page and a child page with the same slug from the course.
// More info here https://www.radiocastvps.com/how-to-redirect-to-a-page-after-completing-a-learndash-course/
wp_redirect(site_url("/congrats/$slug_url"));
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment