Home Forums ACF PRO Consistent data between user and custom post type


Consistent data between user and custom post type

  • I currently create a website for my sports club. Assume the following: I have a cpt named people, which I use a) to present certain club members in the front end and b) collect member specific data like joindate, birthday etc. I now plan to let registered users change some of this data bits themselves, so I manually add a user via a field to the people cpt, if this people is registeted with the website (not every displayed people is a registered user)

    What I have in mind is to hook into the save post process, loop through the fields of the people cpt, and if a user was added, update the user meta with the same values too. If now a user updates his data in the frontend, i would update the peoples cpt meta as well.

    I hope I could explain my situation well enough. Could this be a good way to go, or does anybody have some advice for a better approach?

    Greetings from germany

  • I think that duplication of data will complicate things quite a bit. I would probably use a field user field on the CPT to relate each post to a user. This field could allow null so that if there is not user that matches to post it would just be empty. Then I’d store all my custom data on the CPT.

    Then you can create a front end form with acf_form() and allow them to edit what you want them to edit by specifying the fields to show in the form.

  • Ah, I see. I allready thought that this would be redundant. But I think I try it the other way round: Add an additional Admin visible only profile field to the user profile via the hook edit_user profile, outside of the acf scope to assign the id of the cpt to the user.

    I allready use a self coded frontend login/register process plugin that has hooks inside the edit form and the update user process, should be the right ones to display the additional user editable fields via acf_form nd to update the cpt fields.

    I will post my progress soon hopefully 😉 Thank you for your help so far.

  • Hi

    I’m interested by this thread as I have a related issue. I have created a front end ACF form that uses an ACF field group that allows users to update business details in their my-account pages. However, this is all stored in usermeta which doesn’t bode well when trying to output a listing of all business on a directory page as it is difficult to sort properly. I now want to separate this data from usermeta so I have created a CPT called Business Listings but how do I get this linked to ACF form on at a user level?


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

The topic ‘Consistent data between user and custom post type’ is closed to new replies.