Support

Account

Home Forums ACF PRO Detect incoming and outgoing relations in bidirectional relationships

Solving

Detect incoming and outgoing relations in bidirectional relationships

  • Hi,

    I have managed to set up automatic bidirectional relationships between two posts. I am using ACF Extended Plugin for this, but later I’ve discovered John Huebner has successfully achieved this feature with his Post-2-Post plugin.

    What I need to to is to distinctly record incoming and outgoing relationships.

    Let me explain:

    a) I have a court case X and another court case Y.

    b) X case refers to Y.

    Here I can relate these two cases, but it is not apparent which case refers to another. Only obvious thing is that these two cases are related.

    I remember this question was asked a couple of years ago, but I couldn’t find the exact forum thread. Mr. Huebner was saying this is possible, by recording the incoming and outgoing relations in two different records in the database.

    Are there any updates about the issue? How can I achieve this?

    Thanks.

  • Mr?

    I remember a discussion like this, unfortunately, I don’t remember the specifics of it or what I was thinking at the time I might have suggested it…..

    …. Did some more looking and I did find it. It was over 4 years ago and it was on the WP support forum for my plugin. Still can’t remember WTH I was thinking. Recording where the relationship was created would be incredibly difficult to record and maintain. Not to mention that I’d need to create some type of a usable function to allow you to get incoming vs outgoing relationships.

    One of the things about my plugin is that it is build for an extremely simple use case that requires exactly zero additional coding for that use case. This is the only reason that it still exists.

    How I would do this if I had to do this.

    I would build 2 relationship fields. I would not use a plugin. One of these fields would be editable, the other would not be editable and I would remove this field from the post editor using an acf/prepare_field filter. Or I would somehow disable this field using JavaScript or hide it using CSS.

    I would then code a 2 way relationship between these 2 fields. When saving a post I would update the hidden field based on the editable field. This way the field that is editable always refers to the “To” or “Outgoing” relationships and the hidden field always refers to the “From” or “Incoming” relationships.

    If I wanted to show both the outgoing and incoming relationships I would try to figure out how to make the incoming field read only or in some why not editable. I don’t know if that is actually possible so as a last resort I would create a message field and using an acf/prepare_field filter I would dynamically populate the message with a list of the incoming relationships with links to edit those posts.

    In this way I would have both incoming and outgoing relationships available in different fields and could use them as needed.

  • Thank you for your reply.

    “Mr?” Yes, I’a lawyer 🙂

    I’ve decided to make a comparison between the current post ID and the related post IDs. If the post ID is greater than related post ID, then it means that it is an incoming relation. At least this applies to my situation.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.