Skip to content

Instantly share code, notes, and snippets.

@funkysoul
Created May 25, 2020 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkysoul/ce11aebb5821e5ce676b2a9d6e463018 to your computer and use it in GitHub Desktop.
Save funkysoul/ce11aebb5821e5ce676b2a9d6e463018 to your computer and use it in GitHub Desktop.
jQuery.ajax({
type : "post",
dataType : "json",
url : wpajaxurl.ajaxurl,
data : {action: "signupform", form_id : 37 },
success: function(response) {
if(response.success) {
jQuery('#formcontainer').append(response.form);
}
else {
alert("no matching form found");
}
}
});
function stf_grab_signupform() {
$catID = $_POST['form_id'];
$formID = 37;
/*switch($catID) {
case 'a':
$formID = 37;
break;
case 'b':
$formID = 38;
break;
case 'c':
$formID = 39;
break;
}*/
$formToShow = gravity_form( $formID, false, false, false, '', true, 1, false );
echo json_encode(array('success' => true, 'form' => $formToShow));
$result = null;
die();
}
add_action( 'wp_ajax_signupform', 'stf_grab_signupform' );
add_action( 'wp_ajax_nopriv_signupform', 'stf_grab_signupform' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment