Skip Navigation

[Resolved] Expire by date

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to set CRED different post expiration date for each CRED post created.

Solution:
You should add date field to your CRED form and then use date field value and assign it to CRED expiration and use CRED API hook 'cred_save_data'.

You can find proposed solution with the following reply:
https://toolset.com/forums/topic/expire-by-date/#post-406680

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-api/#csd

This support ticket is created 7 years, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 23 replies, has 2 voices.

Last updated by stewartE 7 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#413411
expire-field.PNG

Hi Minesh

So this is what should be happening (refer back to the private post if you need to check the urls)

1) I create a job post using the cred form embedded in the /create-job page
2) I fill in all the fields in this from- title, overview etc and add an expiry date using the generic field (see screenshot)
3) When I hit submit the job is posted to the the list on the /internal-vacancies page
4) When the expiry date (that I previously set) passes the job post is deleted so it no longer shows on the /internal-vacancies page

Note - The code that you previously suggested to go in functions.php has been added to a plugin which is activated

Thanks

#413425

Minesh
Supporter

Languages: English (English )

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

I think you mark this ticket resolved by mistake.

I'm about to resolve your issue but I need FTP access details temporarily. Could you please share FTP access details so that I should be able to fix the issue.

#413429

Minesh
Supporter

Languages: English (English )

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

Please follow following steps:

Remove this code from your current theme's functions.php file:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data){
	// if a specific form
	if ($form_data['id']==7067){
        $expiry_date = $_POST['_cred_post_expiration_time']['timestamp'];
            update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
    }
}

Once you remove this coded, please let me know. Site will be start functioning again.

#413440

Thanks Minesh,

So I...

1) deleted the code from my Jobs Expiry plugin
2) Took the code that you added to my functions.php (we not allowed to modify the functions.php in production) and moved it into my Jobs Expiry plugin

I've created a test job to run overnight . Hopefully this should work now - i'll let you know

#413446

Minesh
Supporter

Languages: English (English )

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

Great!!

Even to test what you can do is:
=> Create a new job
=> select expiration date = yesterday , that is 4th july, 26016
=> Wait for 2 mins
=> Check your view after 2 mins, that newly created job will not be displayed on view job listing page

I hope above solution will help you to resolve your issue.

#413729

That all seems to be working now - thanks for all your help with this!

One last question - how do I make the generic post expiry field in the cred form required?

#413731

Minesh
Supporter

Languages: English (English )

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

Glad to hear that now fix is working. Glad to help.

You can set "required":1, to make the generic field required
and "required":0, to make it not required.

#413739

Minesh
Supporter

Languages: English (English )

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

I hope issue is resolved now 🙂

#414042

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.