I have a site where users have one or more mailing addresses stored in their user accounts. Custom post types reference these mailing addresses. If a user adds or changes a mailing address, the existing custom post types need to keep their association with the unchanged mailing address – the one originally associated with the custom post type. I’m trying to figure out the best way to accomplish this. We have a lot of users and a lot of addresses.
I figure that I could add a repeater field for the users with one or many addresses stored per user. Some users will have one, some two, a few will have a dozen. Then I could have the custom post types get assigned a row of this repeater field, and the row number will be consistent and not change even if the user adds more addresses. In this way, addresses could never be deleted and the custom post types will always keep their association to the address that was assigned at the time the custom post was created.
Is this the best way to accomplish this, and if so, how do I add a field to the custom post types that simply holds a repeater row number for this address repeater? I’ve not seen this done in the “standard” stack of backend tools that ACF offers. I’m sure it could be custom programmed.
Is there an easier way?
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!