Filter Since 3.5.1 uncanny-toolkit-pro

uo_ff_maybe_autocomplete_redirect

Filters whether a student should be redirected after completing Filters whether a student should be redirected after completing a form, allowing customization of the post-completion action.

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

Description

This filter allows developers to control whether a student is redirected after completing a lesson or topic. By default, it returns `true`, enabling redirection. Developers can return `false` to prevent redirection, for example, to display a custom success message or initiate other actions. This hook fires after successful form submission within the Fluent Forms integration.


Usage

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

Return Value

The filtered value.


Examples

add_filter( 'uo_ff_maybe_autocomplete_redirect', function( $should_redirect ) {
    // This example disables redirection if the current post is the last lesson in a course.
    // In a real scenario, you might check for specific user roles, course statuses,
    // or other conditions before allowing redirection.

    // Assuming you have access to the current post object, e.g., via $post
    // This is a simplified check. In a real application, you'd likely get the post
    // object through a more robust method depending on where this filter is applied.
    global $post;

    // If we're not on a single post page or if $post is not available,
    // we'll allow the default redirection behavior.
    if ( ! is_singular( 'post' ) || ! $post ) {
        return $should_redirect;
    }

    // Check if the current post is the last in its course.
    // This assumes you have a function like `learndash_next_post_link` available
    // which is commonly used in LearnDash contexts.
    $next_post_link = learndash_next_post_link( '', true, $post );

    // If there is no next post link, it means this is the last step.
    if ( empty( $next_post_link ) ) {
        // Prevent redirection if it's the last step.
        return false;
    }

    // Otherwise, allow the default redirection.
    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/fluentform-lesson-topic-auto-complete.php:742

/**
		 * Filters whether a student should be redirected after completing
		 *
		 * @param bool
		 *
		 * @since 3.5.1
		 */
		if ( false === apply_filters( 'uo_ff_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;

Scroll to Top