Filter uncanny-toolkit-pro

uo_course_timer_timedout_redirect_url

Filters the URL where users are redirected after the course timer times out.

add_filter( 'uo_course_timer_timedout_redirect_url', $callback, 10, 1 );

Description

Filters the URL that a user is redirected to after a course timer times out. Developers can use this hook to set a custom redirect URL, overriding the default home page.


Usage

add_filter( 'uo_course_timer_timedout_redirect_url', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

// Example: Redirect to a specific course progress page when the timer times out.
add_filter( 'uo_course_timer_timedout_redirect_url', 'my_custom_course_timer_timeout_redirect', 10, 1 );

/**
 * Custom redirect URL for course timer timeout.
 *
 * This function allows administrators to specify a custom URL to redirect to
 * when a course timer times out. By default, it falls back to the home URL.
 *
 * @param string $redirect_url The current redirect URL. Defaults to home_url().
 * @return string The modified redirect URL.
 */
function my_custom_course_timer_timeout_redirect( $redirect_url ) {
	// Retrieve the custom redirect setting from the plugin's options.
	// Assuming 'uncanny_pro_toolkit' is the plugin slug and 'course_timer_timeout_redirect' is the option name.
	// In a real scenario, you would likely retrieve this from WordPress options or customizer settings.
	$custom_redirect_post_id = get_option( 'uncanny_pro_toolkit_course_timer_timeout_redirect' );

	// If a custom redirect post ID is set and is a valid post/page.
	if ( ! empty( $custom_redirect_post_id ) ) {
		$custom_redirect_url = get_permalink( $custom_redirect_post_id );
		if ( $custom_redirect_url && ! is_wp_error( $custom_redirect_url ) ) {
			return $custom_redirect_url;
		}
	}

	// If no custom redirect is set or it's invalid, return the default.
	return $redirect_url;
}

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/course-timer.php:984

$timed_out_message         = esc_attr__( 'Are you still working on this section?', 'uncanny-pro-toolkit' );
			$feature_timed_out_message = self::get_settings_value( 'timed_out_message', __CLASS__ );

			if ( '' !== $feature_timed_out_message ) {
				$timed_out_message = $feature_timed_out_message;
			}

			$timed_out_redirect         = apply_filters( 'uo_course_timer_timedout_redirect_url', home_url() );
			$feature_timed_out_redirect = self::get_settings_value( 'timed_out_redirect', __CLASS__ );

			if ( '' !== $feature_timed_out_redirect ) {
				$timed_out_redirect = get_permalink( $feature_timed_out_redirect );
			}

			$disable_performance_timer         = 'true';


Scroll to Top