Is there any hook that gets trigged when the author of a post is modified from the edit post screen?

I can list to the update post hook, but then I will not know whether the author of the post was changed or not.

1
1

There is no special hook to author change.

But you can achieve it by using post_updated hook.

Example:

add_action('post_updated', 'prefix_on_update_author', 10, 3);
function prefix_on_update_author($post_ID, $post_after, $post_before)
{

    if ($post_after->post_author != $post_before->post_author) {
        // author has been changed
        // you can add your own hook here or write your code
    }
}

Here is the codex reference.

Leave a Reply

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