ld_after_course_status_template_container
Filter to add custom content after the Course Status section of the Course template output. Filters the output after the course status section in the LearnDash course template.
add_filter( 'ld_after_course_status_template_container', $callback, 10, 2 );
Description
This filter hook, `ld_after_course_status_template_container`, fires after the Course Status section is rendered in LearnDash course templates. Developers can use it to inject custom content, modify the existing output, or add dynamic elements immediately following the course status display. It provides access to the course ID and user ID for context.
Usage
add_filter( 'ld_after_course_status_template_container', 'your_function_name', 10, 2 );
Parameters
-
$course_status(mixed) - - **$course_id** `mixed`
-
$user_id(mixed)
Return Value
The filtered value.
Examples
add_filter(
'ld_after_course_status_template_container',
'my_learndash_add_custom_content_after_course_status',
10,
4
);
/**
* Add custom content after the course status on the course details page.
*
* This function appends a simple message with the course ID and user ID
* to the output after the default course status information.
*
* @param mixed $value The default empty value passed to the filter.
* @param mixed $course_status The current course status.
* @param int $course_id The ID of the current course.
* @param int $user_id The ID of the current user.
*
* @return string The original value plus any appended custom content.
*/
function my_learndash_add_custom_content_after_course_status( $value, $course_status, $course_id, $user_id ) {
// Only add content if the user is logged in and a course ID is available.
if ( is_user_logged_in() && $course_id > 0 && $user_id > 0 ) {
$custom_message = sprintf(
'<p style="font-size: 0.9em; color: #666;">Additional info: Course ID %d for User ID %d</p>',
absint( $course_id ),
absint( $user_id )
);
$value .= $custom_message;
}
return $value;
}
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-course.php:50
src/templates/single-ld30-course.php:129
src/templates/drip-topic-template_legacy.php:54
src/templates/drip-template_legacy.php:54
<?php
/**
* Filter to add custom content after the Course Status section of the Course template output.
*
* @since 2.3
* See https://bitbucket.org/snippets/learndash/7oe9K for example use of this filter.
*/
echo apply_filters( 'ld_after_course_status_template_container', '', learndash_course_status_idx( $course_status ), $course_id, $user_id );
?>
<?php if ( ! empty( $course_certficate_link ) ) : ?>
<div id="learndash_course_certificate" class="learndash_course_certificate">
<a href='<?php echo esc_attr( $course_certficate_link ); ?>' class="btn-blue" target="_blank"><?php echo apply_filters( 'ld_certificate_link_label', esc_attr__( 'PRINT YOUR CERTIFICATE', 'learndash' ), $user_id, $post->ID ); ?></a>
</div>
<br/>