Need help want to open redirect page in new tab - gravity form

semiauto

Member
Jan 15, 2019
60
12
8
i am using gravity form and i want to open my redirect confirmation page in new tab

Here is code which given by Gravity form doc


add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
if ( isset( $confirmation['redirect'] ) ) {
$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 .= "<script type=\"text/javascript\">window.open('$url', '_blank');</script>";
}

return $confirmation;
}, 10, 4 );


Link: https://docs.gravityforms.com/gform_confirmation/#4-open-the-page-or-redirect-in-a-new-tab

i paste the above code in my child theme function file but it's not working can someone plz help me to fix this.
 
Last edited:

freenulled

Well-known member
Null Master
Trusted Uploader
Mar 29, 2019
283
906
100
check this.. maybe work

Code:
add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
if ( isset( $confirmation['redirect'] ) ) {
$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 .= "<script type=\"text/javascript\">var Window;function windowOpen(){Window=window.open('$url','_blank')}windowOpen();</script>";
}

return $confirmation;
}, 10, 4 );
 
  • Like
Reactions: tanierlyons

semiauto

Member
Jan 15, 2019
60
12
8
check this.. maybe work

Code:
add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
if ( isset( $confirmation['redirect'] ) ) {
$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 .= "<script type=\"text/javascript\">var Window;function windowOpen(){Window=window.open('$url','_blank')}windowOpen();</script>";
}

return $confirmation;
}, 10, 4 );
Thanks, it's working
 
Last edited:
  • Like
Reactions: freenulled

elyxxe

New member
Sep 8, 2020
1
0
1
Possibly a dumb question, but where are you supposed to paste this code for it to work?
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu