miriamdepaula

WordPress: Send mail when pending posts

Jan 19th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. /* Avisa o administrador via e-mail sempre que houver novo post para revisao */
  2. function mail_when_pending_post( $post_id ) {
  3.   $post_status = get_post_status( $post_id );
  4.  
  5.   $email = get_option( 'admin_email' );
  6.   $subject = 'NOVO POST PARA REVISÃO - ' . get_the_title( $post_id );
  7.   $message = 'Um novo post foi enviado para revisão: ' . get_the_title( $post_id ) . "\n\n";
  8.   $message .= 'Clique no link para revisar o post: ' . admin_url() . 'post.php?post=' . $post_id . '&action=edit';
  9.  
  10.   if( $post_status === 'pending' ) {
  11.     wp_mail( $email, $subject, $message );
  12.   }
  13. }
  14.  
  15. add_action( 'save_post', 'mail_when_pending_post' );
Advertisement
Add Comment
Please, Sign In to add comment