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.

gform post submission action order

  1. run23
    Member

    is gform_post_submission action hook called before or after the actual post submission, and additionally, the form's redirect URL and associated queryString isn't called until after the actual post submission, correct?

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  2. David Peralty
    Administrator

    It is called after the actual post submission, and yes, you are correct on your other details. Is there something specific we can help with?

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  3. run23
    Member

    Well, I have a 2 page form. The first page deals with registration details. I have a gform_post_submission() hook that then populates my own database with form 1.

    However, I also generate a new registrationID that I need to pass to form 2, which deals with payment based on the registrationID.

    I was planning on setting $form['confirmation']['queryString']=$registrationID in the post_submission() hook, as well as setting $form['confirmation']['url']=$page2Url to redirect to my form 2.

    However, if the redirect itself happens BEFORE my post_submission() hook, then that won't work, because I'm setting the queryString and url too late.

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  4. run23
    Member

    So essentially, my question is:

    Is the gform_post_submission() hook called before or after the form's redirect URL is performed?

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  5. You should use gform_after_submission rather than gform_post_submission, as gform_post_submission has been deprecated.

    With a little debugging, it looks like gform_confirmation comes first, then gform_after_submission. gform_post_submission comes well after both of them, but again, gform_post_submission is deprecated and was replaced by gform_after_submission. The gform_post_submission hook was sometimes processed in the wrong situations, and that was remedied with the new gform_after_submission hook.

    Hope that helps.

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  6. run23
    Member

    Thanks Chris. So is gform_after_submission() called before or after the actual redirect occurs?

    Posted 7 years ago on Thursday July 26, 2012 | Permalink
  7. run23
    Member

    Chris, from my test it appears that setting the redirect url/queryString in gform_after_submission() doesn't work.

    I need a way to dynamically set the redirect url/queryString based on the form's entered values from the user.

    I can't use gform_confirmation() because it doesn't send the ENTRY object as a parameter, which I need to extract the user entered field values.

    What can I do to accomplish my needs?

    Posted 7 years ago on Thursday July 26, 2012 | Permalink
  8. Can you explain what you want to accomplish, from the beginning here, start to finish? Maybe we can come up with another approach for you.

    Posted 7 years ago on Thursday July 26, 2012 | Permalink
  9. run23
    Member

    I have a martial arts tournament registration site. It will list multiple tournaments on the front page. When the user clicks on a particular tournament, they will be directed to the GF Registration form.

    But each tournament has conditions/rules specific to it, so to accomplish this that tournament's ID is sent as a queryString to the GF Registration form.

    pre_render() is used to lookup the tournamentID from a DB and then dynamically pre-populate the Registration form with values specific for that tournament.

    Upon submit, after_submission() does the following:
    * generate a unique Registration ID (which is the primary key)
    * perform DB INSERT of form entry values using registration ID as primary key
    * set the queryString to the RegistrationID and set redirect URL to the Payment form (these don't work)

    The Payment Form:
    * looks up the registration ID from the Registration table to retrieve the registration details
    * obtains the cost for this competitor (cost depends on what he had chosen in the Registration form)
    * generates encrypted paypal button
    * dynamically generates URL and queryString to paypal (this won't work either)

    I suppose its possible to combine payment and registration into a single form, but there is still the problem of dynamically generating the paypal URL and queryString for the Payment Form that is the same as the original problem in the first place.

    Posted 7 years ago on Thursday July 26, 2012 | Permalink
  10. run23
    Member

    Any ideas? I'd prefer not to, but I think I've found where in the GF codebase I can modify so that gform_pre_submission() will also be sent the ENTRY object. But perhaps there was a reason why you guys decided not to pass the ENTRY object...

    The risk is that an update will mess things up. But at this point, I'm too far into GF to find another solution. Hopefully I can use my hack as a temp solution.

    Posted 7 years ago on Thursday July 26, 2012 | Permalink
  11. run23
    Member

    Will my hack work?

    Posted 7 years ago on Friday July 27, 2012 | Permalink
  12. David Peralty
    Administrator

    I am not sure. I'll forward this thread to a developer to see what he/she thinks.

    Posted 7 years ago on Friday July 27, 2012 | Permalink
  13. run23
    Member

    Any updates on this? Upon further analysis, I think I would have to modify the GF codebase so that a hook is created right after receiving the form submission. While this isn't a difficult change, it definitely stops me from easily upgrading to future versions.

    Would it be possible to add this new hook on your end?

    Posted 7 years ago on Wednesday August 15, 2012 | Permalink
  14. I'll ping the developers again to get their thoughts. Thank you.

    Posted 7 years ago on Thursday August 16, 2012 | Permalink
  15. Ok. What you want to use is the gform_confirmation hook/filter. This hook fires after the form is submitted and the entry is created, so you will be able to do your custom database inserts just like you are in the gform_after_submission, but it also lets you specify/change the confirmation text or in your case, the redirect URL. The following page has an example on how to use this hook.
    http://www.gravityhelp.com/documentation/page/Gform_confirmation

    Posted 7 years ago on Thursday August 16, 2012 | Permalink