Browse: Home / Hooks /

learndash_course_completion_url

apply_filters( 'learndash_course_completion_url',  string $page_url,  int $course_id,  int $page_id )

Filters the course completion URL.


Description #

Before version 4.11.0, it was used to filter the ID/URL of the next course quiz which was incorrect.


Parameters #

$page_url

(string) The URL of the course completion page.

$course_id

(int) Course ID.

$page_id

(int) The ID of the course completion page.


Return #

(string) The URL of the course completion page.


Source #

File: includes/course/ld-course-functions.php


Examples #

Note: Extended code example below not guaranteed, you may need to consult with a developer

 <?php
/**
 * Example usage for learndash_course_completion_url filter.
 */
add_filter(
	'learndash_course_completion_url',
	function( $link, $course_id ) {
		// You can change the link here
		if ( $course_id == 123 ) {
			$link = get_permalink( 456 );
		} elseif ( $course_id == 456 ) {
			$link = get_permalink( 789 );
		}

		// Always return $link
		return $link;
	},
	5,
	2
);

add_filter(
	'learndash_course_completion_url',
	function( $link, $course_id ) {

		// Change $course_id to the completed course
		if ( $course_id == 33749 ) {

			// Change to the next couese ID
			$link = get_permalink( XXX );

		} else {

			// Change to a default redirect or you can add more course redirects later
			// Or don't change the value of $link to let the user return to the completed course URL
			$link = get_home_url();
		}

		return $link;
	},
	5,
	2
);
 

Changelog #

Changelog
Version Description
4.11.0 Added the $page_id parameter and $page_url parameter is always a string.
2.1.0 Introduced.