//post and page updated -send email to admin
function pnr_auto_send_email( $post_id ) {
global $post;
// If this is just a revision, don’t send the email.
if( $post->post_type == ‘post’){
$post_title = get_the_title( $post_id );
$post_url = get_permalink( $post_id );
if ( $post->post_date != $post->post_modified) {
//update
$subject = ‘A post has been updated’;
}
else{
//published
$subject = ‘A post has been published’;
}
$message = $post->post_type;
$message .= $post_title . “: “ . $post_url;
// Send email to admin.
}
if( $post->post_type == ‘page’){
$post_title = get_the_title( $post_id );
$post_url = get_permalink( $post_id );
if ( $post->post_date != $post->post_modified) {
//update
$subject = ‘A page has been updated’;
}
else{
//published
$subject = ‘A page has been published’;
}
$message = $post->post_type;
$message .= $post_title . “: “ . $post_url;
// Send email to admin.
}
}
add_action( ‘save_post’, ‘pnr_auto_send_email’ );
shortcode
// // Send email to admin.
// $message = $post->post_type;
// $message .= $post_title . “: ” . $post_url;
// wp_mail( ‘[email protected]’, $subject, $message );