Home › Forums › General Issues › Editing the post and saving it as a "draft" using acf_form (frontend ACF) › Reply To: Editing the post and saving it as a "draft" using acf_form (frontend ACF)
Since you are not creating a new post but are updating an existing post you can’t use the new_post
argument to make the changes.
What you need to do is create an acf/pre_save_post filter https://www.advancedcustomfields.com/resources/acf-pre_save_post/, this is a filter that is run during the save action for acf_form().
In your filter you’ll need to update the status of the post
add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1);
function my_pre_save_post($post_id) {
// test to make sure this is front end and the right post type
// just in case
if (is_admin() || get_post_type($post_id) != 'your-post-type') {
return $post_id;
}
$args = array(
'ID' => $post_id,
'post_status' => 'draft'
);
wp_update_post($args);
return $post_id;
}
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.