I'm designing a process using a Form. I'm looking to have certain functions executed on form submission but rather than using CRED hooks, it's more appropriate to have the form redirect to a page using a Custom Page Template in my theme where the code will reside and then move the User on to the final destination. I'm looking to have a nonce created which is then verified in the Template.
For simplicity, let's say the page using the Custom Page Template has slug 'do-stuff'. I have tried using CRED's redirect hook to nonce the redirect URL but it's messing with other CRED form redirects. Here's the two ways I've tried:-
add_filter( 'cred_success_redirect', 'custom_redirect_3136', 10, 3);
function custom_redirect_3136( $url, $post_id, $form_data ){
if ($form_data['id']==3136) {
return wp_nonce_url( $url, 'my_nonce', 'nonce_token' );
}
}
add_filter( 'cred_success_redirect', 'custom_redirect_3136', 10, 3);
function custom_redirect_3136( $url, $post_id, $form_data ){
if ($form_data['id']==3136) {
$url = wp_nonce_url( $url, 'my_nonce', 'nonce_token' );
return $url;
}
}
Any ideas please? Thank you!
I changed my code slightly to this:-
add_filter( 'cred_success_redirect', 'custom_redirect_3136', 10, 3);
function custom_redirect_3136( $url, $post_id, $form_data ){
if ($form_data['id']==3136) {
$url = wp_nonce_url( $url, 'my_nonce', 'nonce_token' );
}
return $url;
}
}
I had checked the required format here https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect but hadn't spotted the lack of curly braces in the example so the last line ended up in the wrong place.