Action Since 3.0.0 uncanny-toolkit-pro

learndash-course-heading-after

Fires after the course heading. Fires after the course heading is displayed, providing the course and user IDs.

add_action( 'learndash-course-heading-after', $callback, 10, 2 );

Description

Fires after the course heading is displayed on the single course page. Developers can use this hook to add custom content, modify the surrounding HTML, or trigger other actions immediately after the course title and description. It receives the current course ID and user ID as parameters.


Usage

add_action( 'learndash-course-heading-after', 'your_function_name', 10, 2 );

Parameters

$course_id (int)
Course ID.
$user_id (int)
User ID.

Examples

/**
 * Add a custom notice after the LearnDash course heading if the user has not started the course.
 */
function my_custom_learndash_course_notice( $course_id, $user_id ) {
    // Check if the user has started the course.
    $user_course_status = learndash_course_status( $course_id, $user_id );

    if ( 'not_started' === $user_course_status ) {
        // Get the course object for additional information if needed.
        $course = get_post( $course_id );

        // Display a custom notice.
        echo '<div class="my-custom-course-notice">';
        echo '<h3>Welcome to ' . esc_html( $course->post_title ) . '!</h3>';
        echo '<p>We're excited to have you on board. Start your first lesson to begin your learning journey.</p>';
        echo '</div>';
    }
}
add_action( 'learndash-course-heading-after', 'my_custom_learndash_course_notice', 10, 2 );

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:191

* Fires after the course heading.
				 *
				 * @since 3.0.0
				 *
				 * @param int $course_id Course ID.
				 * @param int $user_id   User ID.
				 */
				do_action( 'learndash-course-heading-after', $course_id, $user_id );
				?>

				<div class="ld-item-list-actions" data-ld-expand-list="true">

					<?php
					/**
					 * Fires before the course expand.


Scroll to Top