Skip Navigation

[Resolved] CRED expire post on date solution

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 6 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#600868

Tell us what you are trying to do? ... Trying to use the solution given at https://toolset.com/forums/topic/set-the-post-expiration-date-within-a-form/

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']);

		}

	}

Thanks a lot.

Nick.

#600993

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#601100

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#601514

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks for all details but still when I try to edit the CRED post form Create Public Blog Posts (5606) it redirect back to CRED form listing page.

Also, still FTP access details not working at this end.

I have set the next reply to private which means only you and I have access to it.

#601899

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#601901

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I forget to share screenshot of the CRED post expiration settings of your CRED form ID 5606.
=> hidden link

#602000

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.

#602007

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - what you have done is correct to not expire post ever.