Last active
December 28, 2015 18:59
-
-
Save quawn/7547409 to your computer and use it in GitHub Desktop.
WP: Notification to Admin or Author upon status change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function authorNotification( $new_status, $old_status, $post ) { | |
if ( $new_status == 'publish' && $old_status != 'publish' ) { | |
$author = get_userdata($post->post_author); | |
$message = " | |
Hi ".$author->display_name.", | |
New post, ".$post->post_title." has just been published at ".get_permalink( $post->ID ).". | |
"; | |
wp_mail($author->user_email, "New Post Published", $message); | |
} | |
} | |
add_action('transition_post_status', 'authorNotification', 10, 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment