Home › Forums › Front-end Issues › Change Post Status on Edit › Reply To: Change Post Status on Edit
Looking back at the code, I think it may have something to do with the call to update post, not sure why that’s in there, either that of the insert post. Looking at it, since we’re updating the post the the insert needs to be removed and an change is needed to the update.
try this.
<?php
function my_pre_save_post($post_id) {
// check for numerical post_id and check post_type
if (!is_numeric($post_id) || get_post_type($post_id) != 'post') {
return $post_id;
}
// update status to draft
$post = array(
'ID' => $post_id,
'post_status' => 'draft' ,
);
// update the post
wp_update_post($post);
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );
?>
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.