I’m using the code found in the doc to open the redirect link in a new tab. But after submitted the form, 2 tabs are opened with the url.
add_filter('gform_confirmation', function ($confirmation, $form, $entry, $ajax) {
$forms = [1, 3];
if (!in_array($form['id'], $forms) || empty($confirmation['redirect']) ) {
return $confirmation;
}
$url = esc_url_raw($confirmation['redirect']);
if ($form['id'] == 1) {
$confirmation = '<p style="text-align:center;">Merci de votre inscription !</p>';
}
if ($form['id'] == 3) {
$confirmation = 'Surveillez vos e-mail :)';
}
$confirmation .= GFCommon::get_inline_script_tag( "window.open('$url', '_blank');" );
return $confirmation;
}, 10, 4 );
What’s wrong ?
Thanks.