Support

Account

Home Forums ACF PRO Front-end form, saving updated fields to new post.

Solved

Front-end form, saving updated fields to new post.

  • I’d like to be able to load a front-end form with data from an existing post, and then save the updated fields to a new post on submission.

    I see that I can use acf/pre_save_post to create a new post to save to, but I’m not sure of the best way to only save updated values. Perhaps using acf/save_post and comparing the two posts?

    Thanks for any suggestions?

  • Hi @influencebydesign

    Thanks for the mail.

    By Hooking into the acf/save_post hook with a priority of higher than 10, you will have access to both the submitted values and the ones existing in the database.

    Using this values, you can access evaluate and create new posts using the

    https://developer.wordpress.org/reference/functions/wp_insert_post/

    Hope this helps.

  • Hi @influencebydesign

    To edit a certain post on the frontend, you would need to assign the post_id to the ‘post_id’ parameter of the acf_form(). You can then intercept the saved values within the pre_save_post by checking if the post id is the same as the one edited on the form.

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

The topic ‘Front-end form, saving updated fields to new post.’ is closed to new replies.