I’m just writing something to get notified if someone comes up with a fix…
@RichB, @karlkinkin, maybe you guys should read that great article posted by @elliot : http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/ and this one also of not done yet : http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/
Here is a quick overview of what I understand from these articles, hope it helps :
According to the atticle called “Using acf_form to create a new post”, by hooking to acf/pre_save_post, the function you assign (my_pre_save_post) receives an ID. This ID comes from the post_id passed to acf_form function. If you pass it “new” instead of a post ID, you can do whatever you want, such as creating a post, plus, your custom fields will be saved automatically if you return a post ID after your custom code is executed. You can also see that the function my_pre_save_post returns the post ID and does nothing else if the ID is different than “new”. This is because the function acf_form does the updating job automatically, so there is no need to hook to acf/pre_save_post here.
Also, by adding the prefix “user_” to your ID, acf_form saves user metas instead of post metas. Ain’t that great !
That said, @RichB, you might need to split your user management and post creation/updating in two separate pages. I don’t know exactly what your use case is but it looks you are calling acf_form with wrong parameters.
Cheers !
Dominic
Elliot, thanks for your reply ! @RichB, did you try passing something like 'post_id' => 'user_'.$current_user->ID
as an arg to acf_form in order to populate your fields ? It worked for me.
Elliot, I used a couple of hacks to get it working but it’s not as clean as your solution. I did that just before I left the office for holidays and I don’t have my code with me and I can’t remember exactly what I did but I’ll get back here with some code snippets in a couple of days…
Cheers !
Dominic
I had the same issue with a Date and time picker field. It updates in the database but text input gets emptied after updating a post in the backend. My field is a conditionnal field. I have other fields of the same type innside repeaters and they work fine in 4.1.7… I had to downgrade to version 4.1.4 in order to get it to work and now it’s fine.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.