7

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.

8

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.