Home › Forums › Front-end Issues › Updating the post_status causing problem in the backend › Reply To: Updating the post_status causing problem in the backend
Hi Jonathan,
After some testing I found that the second function is doing nothing!, everything going through the broken function (inc the status of a new post!), so i removed it.
now this is what I have in function.php using the codex link u posted
works perfectly fine
//for new and updated post status
add_action( 'acf/save_post', 'update_existing_post_data', 10 );
function update_existing_post_data( $post_id ) {
if ( ! wp_is_post_revision( $post_id ) ){
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'update_existing_post_data');
// Update existing post
$post = array(
'ID' => $post_id,
'post_status' => $_POST['acf']['field_55dd90c79e8a6'],
);
// update the post, which calls save_post again
wp_update_post( $post );
// re-hook this function
add_action('save_post', 'update_existing_post_data');
}
}
Please if you can see anything wrong with this point it out as this is not the first time I need to change this part again!.
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.