While I don’t see any documentation on how to do this, and not sure if I can do this with ACF, but its a deal breaker for me if I can’t.
I have a custom post type called ‘School’ with a bnch of custom fields. The CPT is displayed to the user as a profile, I need to give users the ability to edit their profile, in other workds I need theme to be able to edit the ACF fields associated with the profile.
This is the code I’m using for the form, I am currently hard coding the profile post ID in this example, but normally I’d query the db for one post in which the UserID acf field matches the UserID of the logged in user. This works but when I make a change and click the ‘Save Changes’ button, instead of updating the current post, it creates a duplicate post. Its loading the correct info for the profile, but saving to a new post even tho I have the post_id hard coded….HELP!!!!!!
doesn’t work either even tho documentation indicates it should:
/* (int|string) The post ID to load data from and save data to. Defaults to the current post ID.
Can also be set to ‘new_post’ to create a new post on submit */
‘post_id’ => false,
It should be working and I don’t see anything in what you’ve posted that should stop it from working. There must be something on your site that is altering the post ID before it’s getting saved. There are too many possibilities to list, you need to somehow narrow down them down. Could be in the theme or in another plugin.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users