# Email Authors When Their Post Is Published

> Sends the author a short email with the link when one of their posts goes live, whether published by an editor or on schedule.

- Type: PHP
- Runs: Run everywhere
- Category: [Email](https://wpide.com/library/category/email/)
- Tags: email, authors, notifications, editorial
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/email-notify-author-published/

## Code

```php
add_action( 'transition_post_status', function ( $new_status, $old_status, $post ) {
    if ( 'publish' !== $new_status || 'publish' === $old_status || 'post' !== $post->post_type ) {
        return;
    }

    if ( (int) $post->post_author === get_current_user_id() ) {
        return;
    }

    $author = get_userdata( $post->post_author );

    if ( ! $author || ! is_email( $author->user_email ) ) {
        return;
    }

    wp_mail(
        $author->user_email,
        sprintf( 'Your post is live: %s', wp_strip_all_tags( $post->post_title ) ),
        sprintf( "Hi %s,\n\nGood news: \"%s\" is now published.\n\n%s\n", $author->display_name, wp_strip_all_tags( $post->post_title ), get_permalink( $post ) )
    );
}, 10, 3 );
```

## Notes

Authors are not emailed when they publish their own post.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Email Authors When Their Post Is Published" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
