I'm working on a development site. The site contains Listings. Listings are free for 12 weeks. At the end of the 12 weeks, if the user doesn't pay for a full 12 months, the Listing status changes to Draft. The User is sent a reminder 2 weeks before expiry.
Form A is used to create a Listing and sets the Listing to expire after 12 weeks. If the User wants to renew, they are directed to Form B (edit content type) which sets the Listing to expire after 52 weeks (thereby renewing the Listing). At the end of the 52 weeks, they use the same form again to renew for another 52 weeks and so on.
When the User submits Form B, I need two things to happen:-
1. the value of a checkbox needs to change to a different value in the same list.
2. the new expiry date needs to be 52 weeks from the previous expiry date
I've set up this CRED hook to solve point 1:-
add_action('cred_save_data', 'save_data_form_5315',10,2);
function save_data_form_5315($post_id, $form_data)
{
// This is the Listing_Renew form ID
if ($form_data['id']==5315)
{
update_post_meta($post_id, 'wpcf-listing-type', 'Paid');
}
}
Where point 2 is concerned, the new expiry date is calculated on the date of publication but the User might renew the Listing up to 2 weeks before the 12 weeks is up and so they lose out. The new expiry date needs to be 52 weeks from the post's previous expiry date so they always get the full period allowed. How do I achieve this please?