# Redirect Fluent Forms Based on an Answer

> Sends visitors to a different page after submitting a Fluent Forms form depending on an answer, such as separate thank-you pages for each service.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: fluent-forms, redirect, conditional
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/fluentforms-redirect-by-answer/

## Code

```php
$wpide_ff_redirect_form  = 0;            // Form ID (0 = off until you set it).
$wpide_ff_redirect_field = 'department'; // Field name holding the answer.
$wpide_ff_redirect_map   = array(
    'sales'   => '/thank-you-sales/',
    'support' => '/thank-you-support/',
);

add_filter( 'fluentform/form_submission_confirmation', function ( $confirmation, $data, $form ) use ( $wpide_ff_redirect_form, $wpide_ff_redirect_field, $wpide_ff_redirect_map ) {
    if ( (int) $form->id !== $wpide_ff_redirect_form || ! is_array( $confirmation ) ) {
        return $confirmation;
    }

    $answer = isset( $data[ $wpide_ff_redirect_field ] ) && is_scalar( $data[ $wpide_ff_redirect_field ] ) ? (string) $data[ $wpide_ff_redirect_field ] : '';

    if ( isset( $wpide_ff_redirect_map[ $answer ] ) ) {
        $confirmation['redirectTo']          = 'customUrl';
        $confirmation['customUrl']           = esc_url_raw( home_url( $wpide_ff_redirect_map[ $answer ] ) );
        $confirmation['enable_query_string'] = 'no';
    }

    return $confirmation;
}, 10, 3 );
```

## Notes

Set the form ID, the field name and the answer-to-URL map at the top; other answers keep the form's normal confirmation.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Redirect Fluent Forms Based on an Answer" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
