I have been testing this solution and it appears not to work. The post remains published after the expiration date.
Here is what I have in the CRED form:
<label class="cred-label">
Should this post expire in the future? Expiration date
</label>
[cred_generic_field field='expiration-date' type='date' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
</div>
<div class="cred-field cred-field-post_title">
<label class="cred-label">
And here is the code in functions.php:
add_action('cred_save_data', 'set_expiry_date', 10, 2);
function set_expiry_date($post_id, $form_data)
{
// if a specific form - create show
if ($form_data['id']==38851 or $form_data['id']==5606)
{
if (isset($_POST['expiration-date']['datepicker']))
{
// add it to saved post meta
update_post_meta($post_id, '_cred_post_expiration_time', $_POST['expiration-date']['datepicker']);
}
}
Hello. Thank you for contacting the Toolset support.
Well - code you are using looks OK to me.
I need problem URL where you added CRED form and access details in order to check issue.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Well - first of all, the post type "public-blog-post" is not accessible in wp-admin at all. Could you please check why?
=> hidden link
Also, which CRED form you are using - I see multiple CRED forms available belongs to post type "public-blog-post" . Could you please share link of your CRED form as well and where you've added that CRED form?
Also, I try to connect to FTP but its not working. Could you please check and resend me working FTP access details and do mention if I need to use any port.
Ok - I've checked and issue was the post expiration settings was not activated from your CRED form. I've activated it and set by default post expiration for 1 week and the form field "expiration-date" will override the 1 week time.
So, now you should try to create new post using CRED form and set your expiration date as you did before using CRED form and try to resolve your issue and check if post expiration works for you.
Thank you. I had not appreciated that this also needed to be activated.
I'm assuming that if a user does not enter an expiration date using the form, the one set for the form as a whole will apply? If so, I need to have the post never expire if the user does not enter a date on the form entry itself. For now, I have set the form's expiry as 1,000 weeks but ideally it would not expire at all.