Skip Navigation

[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.

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)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von leilaG vor 3 Jahren, 4 Monaten.

Assistiert von: Minesh.

Author
Artikel
#2113491

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>

#2114161

Minesh
Supporter

Sprachen: Englisch (English )

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

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 );
    }
}

Where:
- 17313 is your original form ID.

More info:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
=> https://toolset.com/documentation/programmer-reference/cred-api/

I checked and I found that it works as expected and custom post expiration date is saved correctly - can you please confirm it works at your as well.

#2115089

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?

#2115091

Minesh
Supporter

Sprachen: Englisch (English )

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

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.

#2115103
code.png
formID.png

Yes it's the same on the live site 17313, screenshots attached.

#2115189

Minesh
Supporter

Sprachen: Englisch (English )

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

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.

#2115403

My issue is resolved now. Thank you!