You can get an array of all of the fields on a post by using
get_fields() https://www.advancedcustomfields.com/resources/get_fields/. I don’t know if this will be easier or not. Honestly, I don’t see anything I’d consider “easy” to accomplish what you’re doing.
I’d probably look in a different direction depending on how the files get attached to a post belonging to a user. For example maybe adding a field to attachments that records the user that uploaded it if the user is attaching them or if an admin is making the decision then a field where the admin sets who can download them. There are probably other solutions, still, none of them easy.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.