Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer

up vote 3 down vote accepted
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.

share|improve this answer
3  
Or add_filter('wp_insert_post_empty_content', '__return_true'); – chrisguitarguy May 12 '12 at 21:46
I guess you haven't tried this? The problem is that I get tons of Notice: Undefined property: stdClass::$post_XY in R:\development\xampp\htdocs\wprepo\wp-admin\edit-form-advanced.php on line XY and Warning: Cannot modify header information - headers already sent by (output started at R:\development\xampp\htdocs\wprepo\wp-admin\post-new.php:46) in R:\development\xampp\htdocs\wprepo\wp-includes\functions.php on line 86X. It's exactly the same result as intercepting the query filter and returning ''/false/null. – kaiser May 13 '12 at 13:18
Ok, here's why I am wrong: I checked the 2nd argument inside the filter (see edit of your answer). There I checked if the post_status is draft/pending/auto-draft. The last one is a real problem maker, as on every page-new re-load an auto-draft gets added to the database (which will be cleaned up by wp automagically). If I disable the save process there, then the above mentioned errors jump in. @ChristopherDavis I don't really understand why it works without priority and argument number in your case. – kaiser May 13 '12 at 14:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.