Gravity Forms redirect based on conditions

I want to redirect based on conditions in Gravity Forms.

//REDIRECT BASED ON GRAVITY SELECTIONS
add_filter( 'gform_confirmation_17', __NAMESPACE__ . '\\redirectfilter', 10, 4 );
function redirectfilter($confirmation, $form, $entry, $ajax) {
    GFCommon::log_debug( __METHOD__ . '(): started.' );
    session_start();

    $laatste = $entry['1'];

    if(isset($_SESSION['form'])) {
        GFCommon::log_debug( __METHOD__ . '(): SESSION[form] is set.' );
        $result = array();

        foreach($_SESSION['form'] as $row){
            $result[] = $row;
        }

        if ($result[0] === 'Diesel'   $result[1] === 'Mobiel'  $laatste === 'Kunststof'  ) {

            GFCommon::log_debug( __METHOD__ . '(): Diesel and Mobiel and Kunststof' );

            $confirmation = array('redirect' = esc_url(home_url('/producten/filters/brandstof/diesel/materiaal/kunststof/toepassing-filter/mobiel/')));
        } else {
            $confirmation = "Geen producten gevonden aan jouw criteria";
        }   

    }

    GFCommon::log_debug( __METHOD__ . '(): finished.' );
    return $confirmation;       
}

But I cant seem to get it to work, I have the feeling i'm missing something but I can't find it :/

You can find my Gravity Forms log here: http://pastebin.com/hm5RYpyZ.

Help will be greatly appreciated.

Best Regards,

Dylan Smit

Topic plugin-gravity-forms bug-tracking redirect Wordpress

Category Web


I think there is no need for this approach. You should try this:

  1. Go to Form editor / Confirmations
  2. Create confirmation
  3. At the bottom of the screen you can find Conditional Logic, from there you can select specific field values.
  4. Set Confirmation Type as Redirect

Repeat process for all Confirmation options / redirects you need to offer.

enter image description here

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.