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.

Modify form data after submit

  1. Hi All,
    I tried to search the forums but can't find this.

    I have a form where a user can submit a eps or ai file. Afters submission is use gform_after_submission to convert the eps or ai to PNG and save it to wp-content folder.
    Now i want to save the path to that PNG file in the form, but the form is allready submitted.

    Can anyone give me a push in the right direction to update the form data with this path?

    thanks in advance!
    Seb

    Posted 12 years ago on Wednesday August 8, 2012 | Permalink
  2. Just so i'm clear, do you want to save the path to that PNG file as the value of the value of the upload field the user used to upload the eps or ai file? Or do you want to store the path to the PNG as the value of a different field on the form, which could be a hidden field. Either way you'd have to store the value in an existing field. Which route were you wanting to take?

    Posted 12 years ago on Wednesday August 8, 2012 | Permalink
  3. Hi Carl,
    I was trying to save the value to a hidden field, so in the entries we can view the original and converted. should i use gform_update_meta?

    thanks!

    Posted 12 years ago on Wednesday August 8, 2012 | Permalink
  4. If you want to update the value of the hidden field with the path to the PNG file that was generated, you would simply update the value of the hidden field that you have added to your form to store this data as part of your custom code that is executed using the gform_after_submission hook.

    After you process the uploaded file and generate the PNG file, you would then update the value of the hidden field via it's field id using the entry object.

    Here is documentation for the gform_after_submission hook:

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Here is documentation for the entry object itself:

    http://www.gravityhelp.com/documentation/page/Entry_Object

    Posted 12 years ago on Wednesday August 8, 2012 | Permalink
  5. Hi Carl,
    thanks for your reply!
    Maybe this is a stupid question but never done this before.

    I can fill the field id in the entry object, but how do i save this to the database? Cant find this in de documentation you pointed me to!

    Posted 12 years ago on Thursday August 9, 2012 | Permalink
  6. We don't have an API for that, so you will have to manually insert the value in the wp_rg_lead_detail table. Assuming your hidden field is submitted blank, the following should do the trick:

    global $wpdb;
    $wpdb->insert("wp_rg_lead_detail", array("value" => $url, "lead_id" => $entry["id"], "field_number" => $hidden_field_id));

    `

    Posted 12 years ago on Thursday August 9, 2012 | Permalink
  7. Whoohoo! That's why i couldn't find it in the docs :) This works exactly like I wanted!

    Thank you so much Alex and Carl!

    Posted 12 years ago on Friday August 10, 2012 | Permalink
  8. Alex, Carl,

    so if I'm right we always have to use the field ID, which is the field order. It would be nice if can assign an id in the form editor, so it will be more flexible.

    Posted 12 years ago on Friday August 10, 2012 | Permalink
  9. I am glad it worked out for you. The field ID is not exactly the field order. It is an unique identifier given to the field when it is added to the form. If you sort the field, that ID won't change. You can view the id when mousing over the field in the form editor.

    Posted 12 years ago on Friday August 10, 2012 | Permalink
  10. Thanks for clearing up that one :)

    Posted 12 years ago on Friday August 10, 2012 | Permalink

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