I need a way to disable the save process completely using an action/filter. Something that works (for e.g.:) in the query, posts_clauses or wp_insert_post/save_post/update_post hooks.

So far I only tried to return '';, which gives me tons of errors for missing values for post object parts in the admin UI.

This should happen “silently”, so no errors get thrown when php_error/WP_DEBUG and such are set to TRUE/On.

Btw: I’m not asking for how to disable the autosave feature.

2 Answers
2

function disable_save( $maybe_empty, $postarr ) {
    $maybe_empty = true;

    return $maybe_empty;
}
add_filter( 'wp_insert_post_empty_content', 'disable_save', 999999, 2 );

Because wp_insert_post_empty_content is set to true, WordPress thinks there is no title and no content and stops updating the post.

EDIT: An even shorter variant would be:

add_filter( 'wp_insert_post_empty_content', '__return_true', PHP_INT_MAX -1, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *