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.

Shane
Unterstützer
Sprachen:
Englisch (English )
Zeitzone:
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
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.

Shane
Unterstützer
Sprachen:
Englisch (English )
Zeitzone:
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
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?

Shane
Unterstützer
Sprachen:
Englisch (English )
Zeitzone:
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
I resolved the issue with permalink manager pro support, thank you!