Support

Account

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!