Problem:
I want to populate one Custom Field with the value of several other Custom Fields when saving the post either in the backend or front end.
I know how to display values of the fields, I need to merge values when saving the post.
Solution:
This is not possible natively in Toolset, as it requires custom code.
You can either save the new Custom Values when editing the post in the backend by hooking the custom code to WordPress' action save_post(), or in a Toolset Form, to the action cred_save_data()
That custom code should get the values of all Custom Fields you want to use to populate the last, to be updated field.
Then concatenate them into a new $variable and with that variable, you can update the new post field.
For this you will use get_post_meta() and update_post_meta()
At Toolset Support however we cannot provide "ready to use" Custom Code snippets, according to our Support Policy: https://toolset.com/toolset-support-policy/,
Documentation:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/get_post_meta/
https://developer.wordpress.org/reference/functions/update_post_meta/
https://pastebin.com/u/bedas
Specially https://pastebin.com/2BTbVbcs, https://pastebin.com/A2UMXVUJ https://kb.onthegosystems.com/code-snippet/update-post-titlename-with-a-date-from-a-types-date-cf/
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 |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 7 months ago.
Assisted by: Beda.