Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please share live site access details and setup a test page where you added your form, maybe you would like to create another form so we can test it.
*** 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 have set the next reply to private which means only you and I have access to it.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
Thank you for the login details.
I've submitted a test job that should expire on April the 27th.
Once the CRON job runs I will check and see what happens to the post.
Thanks,
Shane
Hi Shane, I checked and there is no test that has been submitted or that is live.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
I did some digging into this a bit more for you and it appears that the post expiration information isn't being modified in the database.
Can you let me know where you've added the code for the post expiration ?
I will like to do a trace through to see where it is failing to set the value.
Thanks,
Shane
Hi Shane,
The below code is in the functions.php file
//Jobs form set expiry date
add_action('cred_save_data', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
// if a specific form
if ($form_data['id']==4896){
$expiry_date = $_POST['expiration-date']['timestamp'];
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
}
}
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
Thank you after several tests I was able to get this to work now. The correct code should be.
add_action('cred_save_data', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
// if a specific form
if ($form_data['id']==4896){
$expiry_date = $_POST['expiration-date']["datepicker"];
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
}
}
The problem was that you were selecting the wrong identifier for the expiration-date field which caused the custom field for the expiration date not to get update.
This should now be resolved.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
On further checks I noticed that it was still not working.
This lead me to believe that the value of the expiration is being set much later by Toolset forms than the point where the hook is setting the date. This means that our date is being overwritten by the default information.
Now I used a hook that fires later than the cred_save_data hook and this works. I've tested it and the date value is now being set correctly.
add_action('cred_submit_complete', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
// if a specific form
if ($form_data['id']==4896){
$expiry_date = $_POST['expiration-date']["datepicker"];
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
}
}
PLease go ahead and test this and let me know if the date is being set for you as well.
Thanks,
Shane
Hi Shane, that's great! Tested and it is now showing the correct expiry date 🙂
Thank you for your help and support.