Home › Forums › ACF PRO › Bidirectional Relationship, different field names, with get/update fields only › Reply To: Bidirectional Relationship, different field names, with get/update fields only
Just wanted to post that I figured out my errors on this, and now have it working!
First in the filter it should have been
add_filter('acf/update_value/type=relationships', 'bidirectional_acf_update_value', 10, 3);
not
add_filter('acf/update_value/name=related_posts', 'bidirectional_acf_update_value', 10, 3);
referencing the relationship field type
The other issue was when assigning the second field_name and field_key I had a single =
if($field_name = 'artist_releases') { $field_name2 = 'release_artists'; $field_key2 = 'field_5bf7a2e215e5c'; }
if($field_name = 'release_artists') { $field_name2 = 'artist_releases'; $field_key2 = 'field_5bf79ed45b371'; }
should have been
if($field_name == 'artist_releases') { $field_name2 = 'release_artists'; $field_key2 = 'field_5bf7a2e215e5c'; }
if($field_name == 'release_artists') { $field_name2 = 'artist_releases'; $field_key2 = 'field_5bf79ed45b371'; }
This now works for bidirectional relationships with different names.
Thanks!
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.