• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

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

semiauto

Member
Jan 15, 2019
61
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:
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: Babak
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
Possibly a dumb question, but where are you supposed to paste this code for it to work?
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock