Casey

Full-Stack Developer

#wordpress

Replace Gravity Form Submission Value After Submit

<?php
function THEME_gform_post_save($entry, $form) {
  switch($form['id']) {
    case 1:
      // Get ID from parent property hidden field, and update to the property name
      $parent_property = (int) $entry['5'];
      $post_type = get_post_type($parent_property);

      // Validate that user provided a valid property and update
      if($post_type == 'properties') {
        $entry['5'] = get_the_title($parent_property);
        GFAPI::update_entry_field($entry['id'], '5', $entry['5']);
      }
      
    break;
  }
  
  return $entry;
}
add_filter('gform_entry_post_save', 'THEME_gform_post_save', 10, 2);