Actionpress 'pre publish post'?

You must modify the contents of the message before posting it. I could overwrite my own publishing function, but I don't want to do this.

What I would like to do is something like:

add_action('before_publish_post','my_func');
function my_func($content){
    $content = "new content";
    return $content;
}

I looked at publish_post, but that only allows me to change the content of the post that was published, not before.

any help would be appreciated, greetings

+3
source share
3 answers

It must be a filter wp_insert_post_data

+6
source

If I were really cool, I would wait until the anniversary date of this post and do it, but ...

You can also use:

add_action('pre_post_update','alter_post_contents');

, , , . , pre_post_update, , post id , post.php, , , , arg , ....

, .

+2

Source: https://habr.com/ru/post/1772256/


All Articles