Skip Navigation

[Résolu] cred_success_redirect question

This support ticket is created Il y a 4 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Ce sujet contient 1 réponse, a 1 voix.

Dernière mise à jour par julieP Il y a 4 années et 10 mois.

Auteur
Publications
#1489185

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!

#1489191

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.