Tell us what you are trying to do?
I have a post form that has two submit buttons. The main submit button keeps refreshing the same page so the user can keep adding multiple instances of the repeating field group. This works fine. And then I have a second submit button that is supposed to allow the user to "complete" the form submission. I have a cred_save_data hook in my functions.php that detects the existence of this 2nd submit button in $_POST, if it does a few things and then redirects the user to a "thank you" page. So all of this seems to work fine as is. However, as soon as I try to add a jquery confirm dialog to the 2nd button, then it doesn't work. It just keeps refreshing the page and acts as though it's not hitting the cred_save_data hook at all. I have a "if ($form_data['id']==xxx)" in my cred_save_data function -- and again, it works withOUT the jquery confirm, but as soon as I add it in, it doesn't get hit. With my jquery confirm, I'm just simply running submit() on the form that contains both submit buttons. It refreshes the page, which implies the JS is working. But it no longer triggers any of the cred actions. Do you have any thoughts on what might be happening?
Here's the jquery:
$('.btn-confirm-final').click(function(e) {
e.preventDefault();
var c = confirm("Click OK to continue?");
if(c){
$('form#cred_form_1059_1').submit();
}
});
It's working. But it refreshes the page in a way that bypasses the cred_form hooks.
And in my functions.php:
add_action('cred_save_data', 'custom_save_calculator',20,2);
function custom_save_calculator($post_id, $form_data) {
if ($form_data['id']==1059) { // <-- this is definitely the correct form ID
// a few steps that normally work withOUT the jquery confirm()
// ending with...
wp_redirect( get_permalink( 1084 ) );
exit();
}
}
Is there any documentation that you are following?
I've looked through similar issues in your forum, and they all seem to suggest that what I have should work.
Is there a similar example that we can see?
What is the link to your site?
hidden link (It's the form on on the 2nd step of the submission process)