I still haven’t figured this out yet.
Is this the right way? I tried $_POST['content'] = "nothing"
and $_POST['content'] = 0
neither work for me. I’m using following way
function changeContent() {
$_POST['content'] = "nothing";
}
add_action('publish_post', 'changeContent');
I want to change the content before it’s written into the database.
You might check out the
content_edit_pre
filter.Your example would then look like this:
You can read more about this filter in the Codex:
https://codex.wordpress.org/Plugin_API/Filter_Reference/content_edit_pre
Edit:
You can also try the
edit_post_content
filter:Since we have in the file
/wp-includes/post.php
these lines:both of these filters should work, but the filters
*_edit_pre
seems to be on the way out and replaced byedit_*
.