save_post vs post_updated

new to wordpress and php. i would like to write a function that triggers when a specific post has its content updated. came across 2 actions, save_post and post_updated. i’m a little confused as to when to use one over the other. i think the one i need is post_updated, but i’m not too sure. that and i don’t really know how to check if a specific post is updated. i haven’t started much on it yet (at my non coding job), but here is what i have thought up so far, after looking at other suggestions:

add_action(‘post_updated’, ‘test_function’);

function test_function($post_ID, $post_after, $post_before){

//check if a specific post is updated here

$post_content = $post_after->post_content;

$raw_data=array(
‘updated_post_content’=>$post_content,
);

//do something

}

Read more here:: save_post vs post_updated

Leave a Reply

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