Created
August 29, 2016 10:31
-
-
Save mafsdisseny/7bffec8abdc619b53a29825214e7ea58 to your computer and use it in GitHub Desktop.
Send a mail when a post has been updated
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 mafs_updated_send_email( $post_id ) { | |
// If this is just a revision, don't send the email. | |
if ( wp_is_post_revision( $post_id ) ) | |
return; | |
$post_title = get_the_title( $post_id ); | |
$post_url = get_permalink( $post_id ); | |
$subject = 'A post has been updated'; | |
$message = "A post has been updated on your website:\n\n"; | |
$message .= $post_title . ": " . $post_url; | |
// Send email to admin. | |
wp_mail( '[email protected]', $subject, $message ); | |
} | |
add_action( 'save_post', 'mafs_updated_send_email' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment