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.

Examples for a pre submission hook?

  1. Could someone submit an example for the implementation of a pre submission hook?
    I'd like to query (sum) all values of a certain form field and reject form submission if this value is grater than a certain amount.
    I think I can manage to code this if I can see some examples on how to use these queries from the hook and how to reject the submission.

    Posted 12 years ago on Tuesday December 6, 2011 | Permalink
  2. Ok, so I already figured out I'll need to query the wp_rg_lead_details table. I think I'll manage writing this query, but I still need to know:
    - how can I cancel submission
    - how can I notify the user that submission is canceled.

    Kind regards,

    Posted 12 years ago on Tuesday December 6, 2011 | Permalink
  3. There is a basic example of the gform_pre_submission hook on it's documentation page here:

    You are correct that you'll need to query the wp_rg_lead_details table.

    As for how you can cancel the submission, what would be an example of a scenario where you would want to do so that way I better understand what you are trying to implement? Do you want to show a validation error or do you want to show a message and hide the form?

    To notify the user that the submission is canceled, and the response returned to the user on the screen isn't sufficient, you can write PHP to send an email to that user if one of the fiels is an email field or if they are logged in user you can use their user account email address.

    Posted 12 years ago on Tuesday December 6, 2011 | Permalink
  4. Hi Carl,
    Thanks for the answer. Actually I'd like to do somthing like this:
    So the user should get a message that te form can't be submitted because a certain quoata has been reached (so an on screen notification would be ok?).
    Can you provide me some code hints for this?

    Posted 12 years ago on Wednesday December 7, 2011 | Permalink
  5. I'm interested in doing a similar method -- I want to cancel submission and throw an error with a link to a different page.

    I'd love a tip for what kind of function to call to send a message like that back to the screen in place of a success message, and to abort the rest of the submit so the data isn't inserted into wp_rg_lead and wp_rg_lead_details.

    Posted 12 years ago on Friday December 9, 2011 | Permalink
  6. I finally managed to customize my form via the validation hook. Works like a charm.

    Posted 12 years ago on Sunday December 11, 2011 | Permalink
  7. Glad to hear, bartpe. :)

    Posted 12 years ago on Monday December 12, 2011 | Permalink

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