Created
April 29, 2024 15:48
-
-
Save Crocoblock/3b73eab179b665f5079ef3fe55006d74 to your computer and use it in GitHub Desktop.
JetPopup Fix Gravity form action URL in AJAX popup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter("gform_form_tag", function( $form_tag, $form ) { | |
if ( empty( $_POST['action'] ) || $_POST['action'] !== 'jet_popup_get_content' ) { | |
return $form_tag; | |
} | |
$url = $_POST['data']['page_url'] ?? ''; | |
if ( empty( $url ) ) { | |
return $form_tag; | |
} | |
$url = preg_replace( '/#.*$/', '', $url ); | |
$url .= sprintf( '#gf_%s', $form['id'] ); | |
$form_tag = preg_replace( "|action='(.*?)'|", "action='{$url}'", $form_tag); | |
return $form_tag; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment