Skip to content

Instantly share code, notes, and snippets.

@mafsdisseny
Created August 29, 2016 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafsdisseny/7bffec8abdc619b53a29825214e7ea58 to your computer and use it in GitHub Desktop.
Save mafsdisseny/7bffec8abdc619b53a29825214e7ea58 to your computer and use it in GitHub Desktop.
Send a mail when a post has been updated
<?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( 'user@example.org', $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