Home › Forums › Add-ons › Repeater Field › update a acf sub_field with the value from a different sub_field › Reply To: update a acf sub_field with the value from a different sub_field
Hi @renar
I’m afraid you have several mistakes there. The hook should be “acf/save_post”, not “acf/save_post hook”. Here’s an example how I do it:
function my_acf_post_fieldb($post_id){
// Field key where you want to update (c_address)
$field_key = 'field_573d8df4646da';
// The General Info post ID that you want to update
$general_info_post_id = 99;
// Get the saved value from the user profile
$value = get_field('add_full_address', $post_id);
// Check if the value exists or not
if( $value ) {
// Update the repeater field in the selected post
update_field($field_key, $value, $general_info_post_id);
}
}
add_filter('acf/save_post', 'my_acf_post_fieldb', 20);
I’m not sure how did you set the custom field to the General Info post type, so I just assume that you want to update the value on a selected post.
I hope this makes sense 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.