Backdating a Gravity Forms Created Post

This is something that’ll come in handy with forms creating timeline events. You can add a date field to the form and this will change the post date to match it. It might work the other way too, I didn’t try that.

Take note of the notes below as this is setup for the date being field one of the form and for the form having ID 5.

/*
*******
*******
*********************************TIMELINE STUFF****************************
*******
*******
*/
function special_timeline_update($entry, $form){
	$time = rgar($entry, '1');//assumes the gform date field is field 1 if not change it
	$post = get_post( $entry['post_id'] );
	$post->post_date = $time;
	$post->post_date_gmt = get_gmt_from_date( $time );
	wp_update_post($post);
}

add_action( 'gform_after_submission_5', 'special_timeline_update', 10, 2 );//set to run off form 5 if not change it