I remove all other entries attached to the current form an post-id, except the newest entry.
add_action( 'gform_after_submission_3', 'mysite_gform_after_submission_3', 10, 2 );
function mysite_gform_after_submission_3 ( $entry, $form ) {
delete_old_etries_by_post_id( $entry['post_id'], $entry['id']);
}
function get_old_etries_by_post_id( $post_id, $entry_exclude, $form = 3 ) {
$search_criteria = array();
$search_criteria['field_filters'][] = array("key" => 'post_id', value => $post_id);
$entries = GFAPI::get_entries( 3, $search_criteria);
return $entries;
}
function delete_old_etries_by_post_id( $post_id, $entry_exclude_id, $form = 3 ) {
$entries = get_old_etries_by_post_id( $post_id, $entry_exclude_id, $form);
foreach ($entries as &$entry) {
GFAPI::delete_entry( $entry['id'] );
}
}
Replace the 3 with the id of yout form.
In my use case, this is better than deleting all entries.
Althought updating the first/original entry would be better,
anybody managed to fix this? Feel free to share your code.