Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Last active November 27, 2017 14:05
Show Gist options
  • Save mauriciogofas/1310330d46227d6574ca to your computer and use it in GitHub Desktop.
Save mauriciogofas/1310330d46227d6574ca to your computer and use it in GitHub Desktop.
Notifica admin sobre post para revisão
<?php
// Notifica admin sobre post para revisão
function send_mail_post_pending( $post_id, $post ) {
$post_status = get_post_status( $post );
if( $post_status === 'pending' && ! wp_is_post_revision( $post ) ) {
$email = ( '[email protected]' );
$subject = 'Revisar novo post';
$message = 'Título do post: ' . get_the_title( $post ) . "\n\n";
$message .= 'Revisar o post: ' . admin_url( "post.php?post={$post_id}&action=edit" );
wp_mail( $email, $subject, $message );
}
}
add_action( 'save_post', 'send_mail_post_pending', 10, 2 );
// Fim
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment