I have a function inside my plugin that attaches to save_post, and inside that function, I’m seeking to filter the post_content prior to it being saved. However, the content never actually gets changed once its saved. See below where I’m setting $post->post_content = “test”;

add_action('save_post', 'save_post_filter',10,2);

function save_post_filter($postID, $post){
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $postID;
    }
    else
    {
        if($parent_id = wp_is_post_revision($postID))
        {
        $postID = $parent_id;
        $post = get_post($postID);
        }
        $post->post_content = "test";
    }
}

2 Answers
2

The content_save_pre filter is applied to the content before it gets saved in the database. Some default filters hook into it too, for example balanceTags() and wp_filter_post_kses().

Leave a Reply

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