uo_learndash_course_topic_not_available
Filters the filepath when a LearnDash course topic is not available, allowing modification before it's used.
add_filter( 'uo_learndash_course_topic_not_available', $callback, 10, 1 );
Description
Allows developers to modify the file path for the Uncanny Drip Topics by Group course template. Use this filter to provide an alternative template file when a course topic is not yet available, ensuring custom display logic.
Usage
add_filter( 'uo_learndash_course_topic_not_available', 'your_function_name', 10, 1 );
Parameters
-
$filepath(mixed) - This parameter contains the file path of the template being loaded by LearnDash.
Return Value
The filtered value.
Examples
// Filter to modify the template path for when a LearnDash course topic is not available.
// This example allows for custom template loading, for instance, to add additional
// messaging or change the styling of the "topic not available" notice.
add_filter( 'uo_learndash_course_topic_not_available', function( $filepath ) {
// Define a custom template path. In a real scenario, this might be a path
// within your theme's directory or a plugin's specific template folder.
$custom_template_path = get_stylesheet_directory() . '/templates/learndash/topic-not-available-custom.php';
// Check if the custom template file exists.
if ( file_exists( $custom_template_path ) ) {
// If it exists, override the default $filepath with our custom path.
$filepath = $custom_template_path;
} else {
// Optionally, you could log a warning or fallback to another template if
// your custom template isn't found, or just let the original $filepath
// be used (which is what happens if this else block is omitted).
// error_log( 'Custom topic not available template not found at: ' . $custom_template_path );
}
// Always return the (potentially modified) filepath.
return $filepath;
}, 10, 1 ); // Priority 10, accepts 1 argument ($filepath)
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/classes/uncanny-drip-topics-by-group.php:1142
public static function learndash_template( $filepath, $name, $args, $echo, $return_file_path ) {
if ( 'course' === $name ) {
if ( ! class_exists( 'LearnDash_Theme_Register' ) ||
(
class_exists( 'LearnDash_Theme_Register' ) &&
'legacy' === LearnDash_Theme_Register::get_active_theme_key()
)
) {
$filepath = self::get_template( 'drip-topic-template_legacy.php', dirname( dirname( __FILE__ ) ) . '/src' );
$filepath = apply_filters( 'uo_drip_template', $filepath );
}
}
if ( 'learndash_course_topic_not_available' === $name ) {
if ( ! class_exists( 'LearnDash_Theme_Register' ) ||
(
class_exists( 'LearnDash_Theme_Register' ) &&
'legacy' === LearnDash_Theme_Register::get_active_theme_key()
)
) {
$filepath = self::get_template( 'learndash_course_topic_not_available_legacy.php', dirname( dirname( __FILE__ ) ) . '/src' );
$filepath = apply_filters( 'uo_learndash_course_topic_not_available', $filepath );
}
}
return $filepath;
}