Home › Forums › Front-end Issues › acf_form() and post locking
Greetings! I’ve been experimenting with acf_form() lately and I would like to build a project based on it (as it would allow users to work/post/edit outside of wp-admin, using a custom/minimal ui). It’s an awesome feature, yet I’ve realized something: if one or more users are working on the same post on the frontend, there’s no “post locking” whatsoever (https://codex.wordpress.org/Post_Locking), at least as far I can see. Needless to say, the lack of it may lead to data being lost/overwritten by users interacting on the same post.
So I’m left wondering if this is a feature that may be included in the future and/or if someone already found himself in this situation and managed a way around it.
This is something I have not seen come up before, but probably a good question. Because ACF will not know how a particular site needs to work I don’t think you see it added. But this is something you can manage yourself. Before calling ACF form test to see if the post is locked https://codex.wordpress.org/Function_Reference/wp_check_post_lock, if it is then do not call acf_form() and show your own message about the post being locked. You can also lock https://codex.wordpress.org/Function_Reference/wp_set_post_lock and unlock the page. I’m sure there’s more to it.
But no this is not something that ACF does and I cannot recall it coming as a topic here before. You might want to submit the feature request in a new ticket https://support.advancedcustomfields.com/new-ticket/
Using wp_check_post_lock() would allow me to gain a lot of flexibily, I really like to sound of it – unfortunately I may be failing at understanding how to properly use it: I get a “Uncaught Error: Call to undefined function wp_check_post_lock()” both on the front/backend. Could you point me in the right direction perhaps (I understand this is more of a WordPress request at this point, but if you have a few minutes to spare I would appreciate it a lot!).
Meanwhile I’m gonna open up a ticket as you suggested.
Thanks in advance!
I was just reading the documentation before. I checked the code and wp_check_post_lock
is a function, so I don’t know why the error. To be honest, the documentation on the whole post locking thing is not very clear. For example, there’s nothing that I can find to unlock a post, only to lock it. The poor documentation on the subject may be the reason that it’s not something ACF is doing.
Scott Clark has posted a potential solution for this that also applies to Pods and Gravity Forms: https://github.com/sc0ttkclark/wp-post-locking
The topic ‘acf_form() and post locking’ is closed to new replies.
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.