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.

Update A Hidden Field From Post_Submission Hook

  1. Need to update a hidden field in a form with an ID number after the form has just been submitted. The ID is calculated by PHP running in a gform_post_submission hook within the theme's functions.php file.

    I thought about writing directly into the GF database like this:

    $wpdb->query("UPDATE $wpdb->wp_rg_lead_detail SET value = 'New Value' WHERE lead_id = 30 AND field_number = 81");

    However, that doesn't seem to update. No error given, just no update happens.

    Is there a smarter way to do this by calling a function already in the Gravity Forms library?

    Posted 11 years ago on Wednesday February 3, 2010 | Permalink
  2. Out of curiosity and before we can come up with a good solution for this, is there any reason why you are generating the ID *afteR* the post is submitted rather than during the submission process itself?

    Posted 11 years ago on Thursday February 4, 2010 | Permalink
  3. Good question. I'm using the form to collect customer info including credit card billing that is sent to Authorize.net for payment processing. When the processing transaction result is returned by them via XML message, they send back the customer's ID they generated. I'm writing the new customer ID back into the Gravity Forms database. I also need to write the payment status (OK, declined) back into GF plus I want to overwrite the customer's credit card # in the GF form database so only the last 4 digits remain. (I'll let Authorize store that risky info so I don't have to implement lots of security on my end.)

    Given that workflow what do you recommend?

    Posted 11 years ago on Thursday February 4, 2010 | Permalink
  4. Given your scenario, I am not sure there is any other way to do this. You will have to update the tables directly. There is a little error on your sql statement, try the following and it should work:

    $wpdb->query("UPDATE wp_rg_lead_detail SET value = 'New Value' WHERE lead_id = 30 AND field_number = 81");

    As for the credit card number, I wouldn't even store it at your side at all. I would truncate them to the last for on the post_submission_hook instead of doing it after you receive the confirmation from paypal.

    Good Luck!
    Alex.

    Posted 11 years ago on Thursday February 4, 2010 | Permalink