I need help. Thanks in advance. I need a function that update post title and slug with some default title + current date when post status is updated from draft to published.
I use this one to update the post date on status change but I need to add a functionality the title also to be updated (with a default one) plus current date also to be shown in the updated title.
//auto change post date on every status change
add_filter('wp_insert_post_data','reset_post_date',99,2);
function reset_post_date($data,$postarr) {
$data['post_date'] = $data['post_modified'];
$data['post_date_gmt'] = $data['post_modified_gmt'];
return $data;
}
Example:
J. Doe register to my site and publish a new post.
He gives the post some crazy name.
J. Doe's post go to drafts.
After 2 weeks Draft scheduler Plugin takes J. Doe's post from drafts and publish it by changing its status to published.
At this point the desired function has to be able to update the post date with the current date, rename J. Doe's crazy title with a default one, add the current date into the title and update the slug.