Support

Account

Home Forums Backend Issues (wp-admin) Bidirectional relationships and WP All Import Reply To: Bidirectional relationships and WP All Import

  • I guess maybe I’m the only person dealing with this issue, but for what it’s worth, I’ve found a solution.

    I built a special utility to crank through all of my CPTs with these bidirectional relationships and sync them up. It’s based heavily on the ACF acf_update_bidirectional_values() function, but I had to make my own modified version of the function to deal with one specific issue.

    The function assumes that all of the current values already have the proper reciprocal relationship in place, and only handles any changes happening on the current edit. But in my case, only half of the bidirectional relationship exists.

    My version just modifies the definition of $current_values (line 56 in the file acf-bidirectional-functions.php, as of version 6.8.0.1) to be an empty array.

    This change works to make sure the missing values get added, but I should note that it prevents subtractions from working. Still, I think the ACF function could possibly stand to be reworked… right now it assumes that all of the existing values already have the reciprocal relationship.

    When things are working properly, that should always be the case. But as I’ve shown here, there are situations where that is not a safe assumption. (I don’t think it’s _that_ much of an edge case that I am importing data with WP All Import, especially since it has a dedicated ACF add-on.)