Prevent other hooks from firing after wp_update_post() outside of editor

I'm working on a plugin that batch updates post content using a call to wp_update_post(). This all happens outside the editor window, in a batch processing script. My problem is that ACF is firing after I run the wp_update_post() call as I think its because of the save_post hooks that run.

This is blanking all my ACF meta, as the values are not present in the post array at that point in time, so how can I prevent anything else firing on this call?

I've tried remove_all_actions('save_post') and remove_all_actions('acf/save_post') just before the call but its not having any effect.

$updated_post = array(
                    'ID' = $current_id,
                    'post_content' = $post_content,
                );
remove_all_actions('save_post');
$result = wp_update_post($updated_post, true);

Ideally I'd like to use a wordpress api function to update the content, as it will create a revision, whereas a direct SQL update will not.

Topic advanced-custom-fields wp-update-post actions Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.