I’ve created a rather large form in the user’s profile page in the admin. Given that the form is so long, I’m trying to figure out a way to get the form to periodically save the data that has already been entered before the Submit button is pressed. This way, a user who makes it half way down the form doesn’t lose the data they just entered previously if they accidentally close the browser, leave the page, browser r a she’s etc before they’ve had a chance to hit the submit button.
I have no idea where to start doing this..
Have you checked that the new Heartbeat API in WordPress does not already perform this kind of autosave for user profiles (probably not but worth a lookyloo)?
Suppose you might be able to do something using this filter:
Like register a custom JS script which upon visiting the profile page creates a session cookie (or perhaps localstorage for html5). Then you run a timed function every 10 seconds or something which looks into all the fields and saves them by field name -> value..
Then when a person loads the edit page of their profile you check if the cookie is set and if so run through all values and input them in the approriate field (by field name).
This is just a quick idea on how to do it and I have no idea if it’s actually doable 🙂
Jonathan, saving data to a cookie I believe only half solves the problem. Although the data would be saved, it wouldn’t actually be saved to the database. Given the size of my form, I was hoping that I could get the form to automatically save the data already entered into the database during timed intervals and without a refresh of the page. This is probably something that would require Ajax but is outside the realm of my abilities. Was just hoping someone already had a solution.
Yeah that’s true 🙂 It would be more of a failsafe than a way to make sure their input is stored..
I believe it might be possible to achieve with the new heartbeat API but I don’t think it’s been done.. Possibly it currently only supports the posts tables as well. Perhaps we’ll see it in the future!
The topic ‘periodic auto save’ 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!