I need your help to add Post Expiration settings in the frontend form.
So I want my editor input content then set the post expired from frontend form.
Is it possible?
If you have a frontend datepicker on your form you should be able to use the hook below to set this.
add_action('cred_save_data', 'set_expiration_date',10,2);
function set_expiration_date($post_id, $form_data)
{
$forms = array( 35927 );
if (in_array($form_data['id'], $forms)) {
// update post publish date based on generic date field
$timestamp = $_POST['wpcf-user-note-expiration-date']['datepicker'];
$date = date('Y-m-d H:i:s', $timestamp);
if(isset($timestamp)){
$args = array(
'ID' => $post_id,
);
wp_update_post( $args );
// update post expiration date based on generic date field and time calculation
$expiry_timestamp = $timestamp + ( 6 * 60 * 60 );
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_timestamp );
}
}
}
What you will need to do is to change the '35927' to the ID of your form and change 'wpcf-user-note-expiration-date' to the slug of your date field inclusive of the wpcf- prefix.
You can add this custom code in Toolset -> Settings -> Custom code and activate it.