How do I know if author field was changed on post save?

I’m writing a plugin that sends notifications on various post events.
One of the notifications should be sent when a post is assigned to a different author.
How can I know that the post author was changed ?

Related posts

Leave a Reply

1 comment

  1. Best Hook for that would be wp_insert_post_data

    function wpse44358_filter_handler( $data , $postarr ){ 
        //do your stuff 
        //if ($data['post_author'] == ...
        return data; // make sure you return something 
    }
    
    add_filter( 'wp_insert_post_data' , 'wpse44358_filter_handler' , '99', 2 );