Skip Navigation

[Resolved] Toolset Date Types won't accept Gravity Forms dates

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

This topic contains 4 replies, has 3 voices.

Last updated by j.-michaelA 2 years, 8 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2514263

Tell us what you are trying to do?
We have created a Toolset Post Type for Students and are attempting to post to it from a Gravity form "Add Student Information" form. It uses the Gravity Forms Advanced Post Creation Add-On to populate data in a "Students" custom post type record. Everything on the form posts correctly except for the 7 Date fields.

Gravity Forms stores dates in MYSQL format e.g. 2022-12-10 and Toolset custom post type Date fields appear to store dates in Unix Timestamp format e.g. 1234567890. We are using the Date field types in both the Gravity Forms form fields and the Custom Post Type fields.

How can we convert the date in the Date fields from the Gravity Forms format (yyyy-mm-dd) so that it will post correctly in the Toolset Custom Post Type in Unix timestamp format?

Thanks so much for your help with this. We think Toolset should give us the custom reporting that our client needs. However, this has us stopped until it can be resolved.

Thank you for your help with this.
Mike

Is there any documentation that you are following?
I've looked at all the relevant docs on your site and done extensive Googling on the issue. No luck.

Is there a similar example that we can see?
I've uploaded an export of the Gravity Form that won't post to Toolset Types. It can be downloaded at:
hidden link

What is the link to your site? hidden link

#2514599

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Mike

I think the solution you will need to implement would use the Gravity Forms API to hook into the form submission process, once the submitted post has been saved, and take the dates submitted with the form and convert them to timestamps, then overwrite the saved date fields with the timestamps.

You should be able to use strtotime to covert the dates to timestamps (hidden link), and update_post_meta (https://developer.wordpress.org/reference/functions/update_post_meta/) to overwrite the custom fields.

Bear in mind that Types fields are saved with a 'wpcf-' prefix, i.e. a field with a slug of "due-date" has a post meta key of "wpcf-due-date".

You'll need to consult the Gravity Forms documentation about the available hooks you could use.

#2518447

I have been able to convert the date on a Gravity Forms Add form to a Unix Timestamp and it now correctly posts that date to a Toolset custom post type date field. Everything looks good in the CPT record and we can display the date in a Toolset View.

However, I still cannot get the Student custom post to display at all in a Gravity Forms Edit form. If I go to my WordPress admin page for Student custom posts and manually refresh the post after I first add it, it then correctly displays in the GF Edit form.

My next step is to try using the GF hook, gform_advancedpostcreation_post_after_creation (hidden link) and/or the Gravity Wiz GW_Update_Posts snippet to see if I can get the post to auto-refresh itself immediately after the Add form is submitted. I will be working on it this evening and tomorrow.

Can you recommend a better Toolset solution?

#2518581

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Nothing that I can think of Toolset related that can help on that matter, but if by updating the post it is fixed what about using the native WordPress save_post hook to force an update programmatically?

https://developer.wordpress.org/reference/hooks/save_post/

It is just an idea, but that is the way you would mimic the manual updating. See if it works.

Nothing that I can suggest from the Toolset hooks themselves:

https://toolset.com/documentation/programmer-reference/toolset-hooks/

Thanks.

#2522225

Thank you for pointing me in the right direction.

My issue is resolved now. Thank you!