uo_resume_button_do_not_show_for_completed_course
Filters whether the resume button should be shown for a completed course, allowing conditional hiding.
add_filter( 'uo_resume_button_do_not_show_for_completed_course', $callback, 10, 1 );
Description
This filter controls whether the "Resume Course" button is hidden for completed courses. By default, it's set to `false`, meaning the button is shown. Developers can return `true` to prevent the button from displaying for users who have already completed a course, ensuring a cleaner user experience.
Usage
add_filter( 'uo_resume_button_do_not_show_for_completed_course', 'your_function_name', 10, 1 );
Parameters
-
$ld_course_id(mixed) - This parameter is a boolean value used to determine if the resume button should be hidden for completed courses.
Return Value
The filtered value.
Examples
<?php
/**
* Conditionally hide the resume button if the course is already completed.
*
* The 'uo_resume_button_do_not_show_for_completed_course' filter by default
* allows the resume button to be shown even if the course is completed.
* This example demonstrates how to override that behavior and hide the button
* for completed courses.
*
* @param bool $should_hide The current value of the filter. Defaults to false.
* @param int $course_id The ID of the current LearnDash course.
* @return bool True to hide the resume button, false to show it.
*/
function my_hide_resume_button_for_completed_courses( $should_hide, $course_id ) {
// If the course is already completed, we want to hide the resume button.
if ( learndash_course_completed( get_current_user_id(), $course_id ) ) {
return true;
}
// Otherwise, maintain the default behavior (which is to show the button).
return $should_hide;
}
add_filter( 'uo_resume_button_do_not_show_for_completed_course', 'my_hide_resume_button_for_completed_courses', 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/classes/learn-dash-resume.php:344
return '';
}
}
$ld_course_id = learndash_get_course_id( $step_id );
if ( true === apply_filters( 'uo_resume_button_do_not_show_for_completed_course', false, $ld_course_id ) ) {
if ( learndash_course_completed( $user->ID, $ld_course_id ) ) {
return '';
}
}
$last_know_post_object = get_post( $step_id );