uo_course_timer_data_reset_enabled
Filters whether the course timer reset is enabled for a specific course and user.
add_filter( 'uo_course_timer_data_reset_enabled', $callback, 10, 2 );
Description
Filters whether course timer reset is enabled for a specific user and course. Developers can return `true` to enable reset or `false` to disable it, providing granular control over progress resetting functionality.
Usage
add_filter( 'uo_course_timer_data_reset_enabled', 'your_function_name', 10, 2 );
Parameters
-
$course_id(mixed) - This parameter is a boolean value that determines whether the course timer data reset is enabled for the current course.
-
$user_id(mixed) - This parameter represents the ID of the course for which the timer data is being reset.
Return Value
The filtered value.
Examples
add_filter(
'uo_course_timer_data_reset_enabled',
function ( $enabled, $course_id, $user_id ) {
// Example: Only allow course timer data reset for administrators.
if ( current_user_can( 'manage_options' ) ) {
return true; // Allow reset for administrators.
}
// Optionally, you could add more specific conditions, e.g.,
// if ( get_post_meta( $course_id, '_my_custom_course_option', true ) === 'allow_timer_reset' ) {
// return true;
// }
return $enabled; // Return the original value if conditions are not met.
},
10,
3 // The filter hook accepts $enabled, $course_id, and $user_id
);
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-reset.php:278
public static function reset_course_progress( $user_id, $course_id, $reset_tincanny_data = 'no', $redirect_url = null ) {
$course_id = intval( $course_id );
if ( '-1' !== $course_id ) {
self::delete_user_activity( $user_id, $course_id );
self::delete_course_progress( $user_id, $course_id );
self::reset_quiz_progress( $user_id, $course_id );
self::delete_assignments();
if ( 'yes' === strtolower( $reset_tincanny_data ) && class_exists( 'UCTINCANDatabaseAdmin' ) ) {
self::reset_tincanny_data( $user_id, $course_id );
}
if ( true === apply_filters( 'uo_course_timer_data_reset_enabled', false, $course_id, $user_id ) ) {
self::delete_course_timer_data( $user_id, $course_id );
}
if ( ! empty( $redirect_url ) ) {
wp_redirect( $redirect_url );
exit;
}
}
}