Home › Forums › ACF PRO › Clone field value from Relationship post › Reply To: Clone field value from Relationship post
I know this is an old post and was solved, but wanted to ask, what if the Events fields were in repeater fields? I tried to modify as below, but not getting the right results.
add_action('acf/save_post', 'save_event_update_address', 20);
function save_event_update_address($post_id) {
if (get_post_type($post_id) != 'events') {
// not and event post, bail
return;
}
// get location post ID
// you said it's a relationship field, a relationship field will turn an array of posts
// I am setting the 3rd parameter because we only need the IDs
$related_places = get_sub_field('relationship_field_name');
// also the
if ($related_places) {
$place_id = $related_places[0];
$address = get_field('address_field_on_place_name', $place_id);
update_sub_field('address_field_on_event_repeater_name, $address, $post_id);
}
}
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.