Hi
I try to build a structure for organizing apartments, families and family members, but I can’t figure how to set it up to fulfil my goal (and to avoid data redundancy).
An apartment consists of one family, a family consists of one or more members and a member belongs to one and only one family.
I have created two CPT and a couple of custom fields:
Families
========
apartment_family (Relationship min 1 and max 1)
family_members (User)
Apartments
==========
apartment_family (Relationship min 1 and max 1))
I can easily connect Families and Apartments via the relationship field (and the ACF Post-2-Post plugin), except that I can’t figure how to avoid adding eg. the same family to more apartments?
When it comes to the Family members it begins to be even shakier:
I can add users but like above, I can’t figure how to avoid adding eg. the same member to more families?
Unlike the Families and Apartments I can’t figure how to make the relation between Families and Users bi-directional. I would like to sync the information about family_members to the Users table. Is this possible?
Or is it possible to create a function that takes the user_id from the users table and look up in Families to view the corresponding family that the current user belongs to?
I hope it makes sense to someone, so I can get further. Maybe the solution is to create one more CPT eg. some kind of an index that holds information about family and members?
All help is appreciated 🙂