I have a button to duplicate my posts from the frontend using this hook:
//Duplicate posts
add_action('cred_save_data_376', 'duplicate_post', 10, 2);
function duplicate_post($post_id, $form_data) {
// get data of original post
$post = get_post( $form_data['container_id'], ARRAY_A );
// update the new post with this data
$post['ID'] = $post_id;
$post['post_title'] = 'Copia de ' . $post['post_title'];
$post['status'] = '_draft';
wp_update_post( $post );
// get fields of original post
$fields = get_post_custom( $form_data['container_id'] );
// update the new post with these fields
foreach ($fields as $key => $values) {
foreach ($values as $value) {
add_post_meta($post_id, $key, $value, false);
}
}
}
And this other Hooks to get todays date and +365 days:
//Todays date
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return time();
}
//+365 date
add_shortcode('wpv-post-masdias', 'masdias_shortcode');
function masdias_shortcode() {
return strtotime('+365 days', time());}
What I need is to duplicate the post and use the todays date for [wpcf-fecha-de-inicio'] (post start date) and +365 days date to [wpcf-fecha-de-fin] (Post end date).
How can I add this to the hook?