learndash-course-certificate-link-after
Fires after the course certificate link. Fires after the course certificate link is generated, providing access to the course and user IDs.
add_action( 'learndash-course-certificate-link-after', $callback, 10, 2 );
Description
Fires after the course certificate link is displayed for a specific user on the single course page. Developers can use this action hook to add custom content or modify the output immediately following the certificate link, utilizing the provided `$course_id` and `$user_id` parameters.
Usage
add_action( 'learndash-course-certificate-link-after', 'your_function_name', 10, 2 );
Parameters
-
$course_id(int) - Course ID.
-
$user_id(int) - User ID.
Examples
// Example: Add a custom message after the course certificate link if the user has completed the course.
add_action(
'learndash-course-certificate-link-after',
function( $course_id, $user_id ) {
// Check if the user has actually completed the course.
// This is a simplified check; in a real-world scenario, you might use LearnDash's built-in completion functions.
$course_completed = learndash_is_user_complete( $course_id, $user_id );
if ( $course_completed ) {
echo '<p class="learndash-certificate-completion-message">Congratulations on completing this course! You can download your certificate above.</p>';
}
},
10, // Priority: Default is 10
2 // Accepted args: The hook passes $course_id and $user_id, so we accept 2 arguments.
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/templates/single-ld30-course.php:97
* Fires after the course certificate link.
*
* @since 3.0.0
*
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-course-certificate-link-after', $course_id, $user_id );
/**
* Course info bar
*/
learndash_get_template_part(
'modules/infobar.php',