I have a problem with editing post with the acf_form() function.
Right now I have a CPT set up and a field group connected to that.
I’ve built an upload page where users can upload their own post with the acf_form() function and that works fine.
I figured that users should also be able to edit uploaded content so I added a form that only shows when the user is the creator of the post. This form can be used to edit every single field used to create the post. After pressing update on the form all the changes appear and are visible on the backend as well. At least until I reload the page after visiting another, then all the edited changes are gone.
I used the acf_form_head function in the head and this in my body
The shortcode creates a button that hides and shows the form.
I did some research and found out that maybe acf/pre_save_post would be an option but I couldn’t figure out how to set this up. It seems that the posts need to be updated after making changes wich doesn’t happen automatically and so it has to be done manually wich doesn’t work out for me.
I hope someone can help me with that.
I don’t see anything in what you provided that would cause the post not to update. From the look of it you are including the form on the same post that the content is associated with, that is the single php template for the post type, whatever that is.
If this is not the case and you are showing this form on some other post or page on the site then you need to provide the correct post_id argument when calling acf_form().
If that’s not a problem then maybe you’re seeing some kind of a caching issue. Do you have a cache plugin running on the site?
Viewing 2 posts - 1 through 2 (of 2 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