title: Wordpress: Don't manage to retrieve author's name from php function
body: <p>I'm creating a function that sends an email to a mailing list when a post is published on my WordPress blog.</p>
  
  <pre><code>function announce_post($post_id){
      $email_address = 'address.of@the-mailing.list';
  
      $subject = "New Post: " . get_the_title($post_id);
      $body = "Hi,\r\n\r\n" .
          "SOMEONE has just published the article \"" . 
          get_the_title($post_id) . "\" on \"BLOG TITLE\".\r\n\r\n" .     
          "You can read it at " . get_permalink($post_id) . "\r\n" .
          "or visit BLOG_ADDRESS.\r\n\r\n" .
          "Best wishes\r\n" .
          "The Publisher";
  
      if (wp_mail($email_address, $subject, $body, "From: \"BLOG TITLE\" &lt;address.of@the-blog&gt;")) { }
  }
  
  add_action('publish_post','announce_post');
  </code></pre>
  
  <p>As it is the function works well, but of course I would replace the <code>SOMEONE</code> with the actual post's author name. And I don't manage to retrieve that.<br>
  Neither <code>get_the_author($post_id)</code>, <code>get_post_meta($post_id, 'author_name', true)</code> nor anything else I tried and can't recall worked. Everything just returned <code>""</code>.</p>
  
  <p>So what is the correct way to retrieve the post author's name, given a post id?</p>