I don’t know how your front end form saves its data, but presumably it is using wp_insert_post
and wp_update_post
. If so, there is a filter called wp_insert_post_data
that can be used to alter the post data before the post is inserted or updated.
function reset_post_date_wpse_100021($data,$postarr) {
var_dump($data,$postarr); die; //debug
// your code
return $data;
}
/**
* runs before new posts have IDs !!!
*/
add_filter('wp_insert_post_data','reset_post_date_wpse_100021',99,2);
The second parameter is your $_POST
data plus the old database data with the $_POST
data overwriting the old data where they conflict.
If you look at the var_dump
of that $postarr
value you should see your datepicker data. You need to chop up your datepicker data and overwrite the date values in the $data
array.
The issue I see is that WordPress (and MySQL) uses 0000-00-00 00:00:00
— Y-m-d H:i:s
— as the datetime format. That is what you need to provide, but you don’t mention a time component at all. At the very least tack 00:00:01
onto your date.
That should be all you need.