PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Redirect after form submission

  1. Hi

    I am trying to change the redirect location of a form based on data checked within gform_after_submission. I was wondering where to trigger the gform_confirmation filter?

    Essentially what is happening is this:

    /** Set location to redirect to if the email address is changed */
    function changed_username_redirect($confirmation, $form, $lead, $ajax){
        $confirmation = array("redirect" => site_url('/login/?updated=profile'));
        return $confirmation;
    }
    
    /** Update user profile after form is submitted */
    function my_profile_update( $entry, $form ) {
    
        // I have functions to update the user's profile here
    
    	// If user's email address has changed
    	if ( $user_email != current_user_email() ) {
    
    		// Change redirect location as we will be booted out
    		add_filter('gform_confirmation_4', 'changed_username_redirect', 100, 4);
    
    	}
    
    }
    
    add_action( 'gform_after_submission_4', 'my_profile_update', 100, 2 );

    But it is not picking up the change in confirmation redirect.
    Do I have something wrong in the position / ordering of the filter?
    Am I able to change the redirect location, or do I need to trigger the filter earlier?

    Thanks

    Posted 12 years ago on Friday November 9, 2012 | Permalink
  2. Never mind, I figured it was too late to change the redirect after form submission.

    I put the gform_confirmation filter inside a gform_validation filter (testing if the email address was being changed) and it worked nicely.

    Posted 12 years ago on Friday November 9, 2012 | Permalink
  3. David Peralty

    Glad you were able to figure it out.

    Posted 12 years ago on Friday November 9, 2012 | Permalink

This topic has been resolved and has been closed to new replies.