Skip Navigation

[Resolved] Automatically updating a field of the post parent

This support ticket is created 2 years, 10 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 2 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2298909

On my site, I catalog climbing routes.
Using a Post Form, users can create a post child. That is their performance on a climbing route.

On that Post Form, they can suggest modifying a custom field of the parent post.

Is it possible to create a system that, if 10 users insert the same data on a custom field, automatically updates the custom field of the parent post?

#2299621

Hello,

There isn't such kind of built-in feature, one post form can handle one post, in your case, you might consider custom codes, for example:
1) after user submit the child post form, use action hook cred_save_data to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

2) In this PHP function
Get current child post custom field values:
https://developer.wordpress.org/reference/functions/get_post_meta/
get the related parent post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
and update custom fields of parent post:
https://developer.wordpress.org/reference/functions/update_post_meta/
If those custom fields are created with Toolset Types plugin, you need to use "wpcf-" field slug prefix in your custom PHP codes, for example "wpcf-my-field"