[Gelöst] Post expiry date in form saves a different date in the post
This support ticket is created vor 3 Jahren, 4 Monaten. 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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Post expiry date in the form saving as different date in the actual post.
I have pushed a fresh copy of the live site to staging site
versteckter Link
I submitted this form with expiry date: 18/07/2021 when you go into the post the date is showing 10/08/2021 versteckter Link versteckter Link
FYI - I removed recaptcha in the form as it was giving an error because it's the staging site/domain
ERROR for site owner: Invalid domain for site key
[cred_field field='recaptcha' value='' urlparam='' class='form-control' output='bootstrap']
<br>
Hello. Thank you for contacting the Toolset support.
Post expiration time is saved with the meta key namely "_cred_post_expiration_time" that holds the date field value as unix timestamp.
That is why we will require to save the timestamp with the post meta key "_cred_post_expiration_time".
I've added the following code to "Custom Code" section offered by Toolset:
=> versteckter Link
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']==17313){
$expiry_date = $_POST['expiration-date']['timestamp'];
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
}
}
Thank Minesh, strange it's worked for the last 3 years.
I tested on staging site, it's working again now, but I added the code to our live site and tested, but its not working on the live site. Are there any other settings or code I need to add or change?
No - I just added the code I shared and I can see it working. Please make sure you replace the original form ID, on staging its 17313 - it may be different on your live site.
Is the code snippet you added is active? if not, can you please activate it. If that does not help I will require admin access details to your live site with problem URL where you added the form.