Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Created April 29, 2024 15:48
Show Gist options
  • Save Crocoblock/3b73eab179b665f5079ef3fe55006d74 to your computer and use it in GitHub Desktop.
Save Crocoblock/3b73eab179b665f5079ef3fe55006d74 to your computer and use it in GitHub Desktop.
JetPopup Fix Gravity form action URL in AJAX popup
<?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