Support

Account

Home Forums General Issues Saving post data after page is refreshed

Solving

Saving post data after page is refreshed

  • Hi, I’m new to both WordPress and ACF.

    GOAL: I’m trying to create a new ACF post type that will let user enter a form of data, save them in “field” and display them right away on the same post.

    ISSUE: When I reload (F5 refresh) the page, all my “field” data will be gone.

    I tried searching around “save_post”, “update_value”… those do not seem to be what I needed (or possibly I didn’t use them correctly 🙁 ).

    I know I can possibly save my data in some text files and reload them once the page is refresh. However I wonder if there is more elegant way (existing) WP/ACF function that can retain the post data after page is refreshed.

    Any hint or pointer to other post will be greatly appreciated! 🙂 Thanks million in advance!

  • Hi @clark0820

    Sorry, but I don’t understand your GOAL.

    Can you please be more descriptive with your issue?

    Is this on the front or back end of the website?
    What does your field group look like?
    What is the post type?
    Why is ‘reload’ an issue? Do you save the data before reloading?

  • Hi Elliot,

    Sorry for being unclear.

    So, say I’m using the “Text Area” field type.
    I would like to save whatever the user typed in the Text Area.

    e.g.
    i) There is Default value “placeholder text” once the post is loaded
    ii) User click into the “Text Area” post, change all the text to be “user data”
    iii) User refresh the page by hitting F5
    iv) After refresh, the post is showing “user data” instead of “placeholder text”

    I’m not so sure what ACF function to call to save the data once the client side has completed their action. (I can possibly save them in a text file and then reload them when I’m calling “create_field”, but I’m hoping ACF can save the data so I can avoid saving the data myself)

    Hope the example above made my Goal a little bit more clear. This may just be a very basic question. I tried searching around, but don’t know how to achieve this.

    Thanks!

  • Hi @clark0820

    Is this a custom form on the front end of a website? Or the ACF created form in the backend when editing a post?

    ACF contains no functionality to auto save upon change, only when you click the save button.

    Perhaps your browser is caching the value, which explains why it appears again in the form. Perhaps you need to perform a hard refresh to get the default value?

    Can you please shed some light on where this texarea is and how ACF is related.

    Thanks
    E

  • Thanks Elliot for the response.

    This is a frond end of a website.

    So, if I’m to add this “save button”, what acf function should I call? Any example for this out there?

    Sorry again for the confusion. I actually do not want the default value the example I showed is what I wanted.

    This is a custom post that I created. I just add this in the field group using “custom field”, and see it in the front post page.

    Thanks

  • Hi @clark0820

    Please read the docs to learn about the update_field function.

    Thanks
    E

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Saving post data after page is refreshed’ is closed to new replies.