wordpressgravityforms

How to change the value of a gravity form entry after the entry is already created


I have a hidden gravity form field that needs to be given a value after the entry was already created and the value needs to show in the form entries in the backend of WordPress.

I think I might be on the right track with this:

add_action('gform_after_submission_8', 'set_job_num', 10, 3);
function set_job_num($post_id, $entry, $form){
  $post = get_post($post_id);
  //Do something here to find and update field ID 57 for form ID 8
{

I just need to know how to find the field I'm looking for and update the post with the new field value.

Thank you!


Solution

  • Solution:

    add_action('gform_after_submission_8', 'set_job_num', 10, 3); // The 8 is the ID of the form
    function set_job_num($entry, $form){
     $updated_entry = GFAPI::get_entry( $entry['id'] ); // ID of entry we want to update
     $field = '57'; // ID of field we want to update
     $updated_entry[$field] = 'New Value'; // The new value
     $updated = GFAPI::update_entry( $updated_entry );
    {