Newbie – submission redirect not opening new window

I’m trying to create a Download Form so customers enter their details to download a PDF and get redirected to the PDF on submission. I want the PDF/page to open in a new window though and the code I’m using doesn’t do that. When I add the code from ( and adjust the $forms to ID 1, it actually returns a Text confirmation.

I’m a bit of a newbie and am still learning, so it’s probably something very simple I’ve left out…

This is the code I have used:

add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
    GFCommon::log_debug( 'gform_confirmation: running.' );
    $forms = array( 1 ); // Target forms with id 3, 6 and 7. Change this to fit your needs.
    if ( ! in_array( $form['id'], $forms ) || empty( $confirmation['redirect'] ) ) {
        return $confirmation;
    $url = esc_url_raw( $confirmation['redirect'] );
    GFCommon::log_debug( __METHOD__ . '(): Redirect to URL: ' . $url );
    $confirmation = 'Thanks for contacting us! We will get in touch with you shortly.';
    $confirmation .= GFCommon::get_inline_script_tag( "'$url', '_blank');" );
    return $confirmation;
}, 10, 4 );

Any help would be greatly appreciated : )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.