Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php function email_author_about_publishing() {
  2. global $wpdb, $post_ID;
  3.  
  4. $users = $wpdb->get_results( "SELECT ID FROM $wpdb->usermeta WHERE meta_key = 'wp_user_level' && meta_value > 0" );
  5. $post = $wpdb->get_row( "SELECT post_author, post_title FROM $wpdb->posts WHERE ID = " . $post_ID );
  6. $authordata = get_userdata( $post->post_author );
  7.  
  8. $blogname = get_settings( "blogname" );
  9. $subject = "Your post has been published!";
  10.  
  11. $text ="Ciao ". $authordata->user_nicename . ",";
  12. $text = $text . "\n\nYour post " . $post->post_title." has been published.";
  13. $text = $text . "\n\nYou can read it here: " . get_permalink( $post_ID );
  14.  
  15. mail( $authordata->user_email,
  16. $subject,
  17. $text,
  18. "From: " . $blogname . " <" . get_settings( "admin_email" ) . ">" );
  19.  
  20.  
  21. }
  22.  
  23. add_action('publish_post', 'email_author_about_publishing');
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement