Skip to content
Advertisement

How to auto update an acf field based on the condition?

I have two custom post types with acf fields.
Custom Post_A, which has 2 fields – title / submitted
Custom Post_B, which has 2 fields – title / percent
Both Post_A and B have the same title (which is the logged in user’s name) and they already exist.

When a field ‘submitted’ has the value ‘done’ in Post_A, I need to automatically update a ‘percent’ field with a value ‘50’ in Post_B.
I tried the following code but it doesn’t update ‘50’ to Post_B.
Would you please correct my code?

JavaScript

Thank you.

Advertisement

Answer

You can use save_post_{$post->post_type} action hook that will trigger on specific post type. check the below code.

JavaScript

USEFUL LINKS

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement