uo_frm_maybe_autocomplete_redirect
Filters whether a student should be redirected after completing Filters whether a student should be redirected after completing a form.
add_filter( 'uo_frm_maybe_autocomplete_redirect', $callback, 10, 1 );
Description
Fires before a student is potentially redirected after completing a lesson or topic. Developers can use this filter to prevent the redirect by returning `false`. This hook is useful for custom redirect logic or preventing redirects entirely in specific scenarios.
Usage
add_filter( 'uo_frm_maybe_autocomplete_redirect', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Prevent redirection after completing a lesson/topic if the user is on a specific course.
*
* This example demonstrates how to use the 'uo_frm_maybe_autocomplete_redirect'
* filter to conditionally disable the redirect.
*/
add_filter( 'uo_frm_maybe_autocomplete_redirect', function( $should_redirect ) {
// Check if the current post is a lesson or topic.
// This check is often done within the function that applies the filter,
// but for a self-contained example, we'll assume this is the context.
// In a real scenario, you'd likely pass the current post ID or object
// to the filter function if it wasn't already available in the scope.
// For demonstration purposes, let's assume we want to disable redirection
// for a specific course, identified by its ID.
$specific_course_id = 123; // Replace with the actual course ID
// Get the current course ID associated with the lesson/topic.
// This logic might vary depending on how your theme/plugins handle course associations.
// For LearnDash, you might use something like:
$current_course_id = learndash_get_course_id_for_step( get_the_ID() );
// If the current lesson/topic belongs to our specific course,
// and the original value was true (meaning a redirect was intended),
// we'll change it to false to prevent the redirect.
if ( $current_course_id === $specific_course_id && $should_redirect === true ) {
return false; // Disable the redirect
}
// Otherwise, return the original value to maintain the default behavior.
return $should_redirect;
}, 10, 1 );
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/frm-lesson-topic-auto-complete.php:307
/**
* Filters whether a student should be redirected after completing
*
* @param bool
*
* @since 3.5.1
*/
if ( false === apply_filters( 'uo_frm_maybe_autocomplete_redirect', true ) ) {
return;
}
$next_post_link = learndash_next_post_link( '', true, $post );
$is_last_step = empty( $next_post_link );
$button_link = $next_post_link;