Skip Navigation

[Resolved] How are Toolset custom fields saved?

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

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by xiaolinW 3 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2061507

Hello, how does Toolset exactly save post meta? I'm trying to retrieve custom fields only after post creation(not post update).

I need a hook after a post is created and not updated, but I also need it only when all the custom fields/post meta are saved.

#2061709

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Xiaolin,

Thank you for getting in touch.

Are you creating the post on the backend or is this being done through a frontend Toolset form ?

If through the backend then the hook you will use is the default wordpress save_data hook.
https://developer.wordpress.org/reference/hooks/save_post/

If it is through a frontend Form by Toolset then you can use this hook below.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

Also when retrieving the value from the database using the get_post_meta function you will need to add the wpcf- prefix to the custom field slug.

Please let me know if this helps.
Thanks,
Shane

#2061829

Thank you for reply, but the save_post is not precise, when save_post is called sometimes the custom fields are not saved yet, I need something that is exactly right after the wpcf are all saved.

#2061935

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Xiaolin,

We do not have a hook at the point that you want to intercept the data.

I've checked on the wordpress codex for a hook that is able to do this but there isn't one.

The only action that can be performed is after the post has been saved.

We do have one for before the data is saved but this needs to be used when you're using one of our frontend forms.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data

Thanks,
Shane

#2061945

But I really need to conditionally set the url permalink after all post meta are saved, I can't call save_post as save_post is called many times even before the custom fields post meta are saved. I tried to set save_post priority to 999 but it's still called once with post meta not saved before the post meta are saved by toolset. How do you save the post meta? Which hook do you use to save them?

#2062023

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Xiaolin,

What exactly are you trying to do. Is it that you want to add the custom field value to the URL ? In a case like this you don't need to retrieve the custom field value from the database.

You can just get it from the POST request payload by doing this $_POST['wpcf-my_custom_field_slug']

Thanks,
Shane

#2071217

I resolved the issue with permalink manager pro support, thank you!