Awesome – I got it working!
Thanks everybody for your help and comments. Turns out the function had a problem because it was taking the $data in, but never returning it, because I had “return $data” in my if statement!
Another problem was with the “WPSearch 2″ plugin”, it was breaking my “New Post” functionality – strange 🙁
Here is the completed correct function:
function cfc_reset_postdate( $data ) {
if($data['ID']) { $postarr['ID'] = $data['ID']; }
if($data['post_type'] == 'scripture-memory') {
if($_POST['cfc_date']) {
$date = $_POST['cfc_date'];
$date = DateTime::createFromFormat('D - M j, Y', $date);
$date = $date->format('Y-m-d');
$data['post_date'] = $date;
}
}
return $data;
}
add_filter( 'wp_insert_post_data', 'cfc_reset_postdate', '99', 1);
Hope this function helps anybody who wants to change the post_date with a custom meta-box date.