title: Send email notification when new post from post type is created
body: <p>I'm having a time trying to get this to work and I feel like I have tried everything from <code>transition_post_status</code>, to <code>wp_insert_post</code> and even <code>draft_to_pending</code> for my actions.</p>
  
  <p>I'm trying to send an email to a user and the post author.  The user is set via ACF user object.  The problem I think, is that possibly the meta is not available or something because $author and $user are not objects so it's not finding them by the ID and grabbing their data.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>add_action( 'transition_post_status', 'send_volunteer_request_email', 10, 3 );
  function send_volunteer_request_email( $new_status, $old_status, $post ){
    if ( 'volunteers' !== get_post_type( $post ) )
      return;
  
    if( wp_is_post_autosave( $post ) ) return;
  
    $user = get_field('user', $post);
    $user_data = get_userdata( $user );
    $the_event = get_field('event', $post);
    $event = get_post($the_event);
    $eventLink = get_permalink($event);
    $author = get_userdata( $event-&gt;post_author );
  
    if(get_post_status($post) == 'pending'){
      //Notify event author
      $headers = array('Content-Type: text/html; charset=UTF-8');
      $subject = 'You have a new volunteer';
      $body = '&lt;p&gt;A member has volunteered to meet your need. Click &lt;a href="' . $eventLink . '"&gt;here&lt;/a&gt; to view and accept or decline!&lt;/p&gt;';
      $body .= '&lt;p&gt;Thank you for being a valuable member&lt;br&gt;&lt;a href="https://www.google.com"&gt;https://www.goole.com&lt;/a&gt;&lt;br&gt;910-555-1234&lt;/p&gt;';
      wp_mail( $author-&gt;user_email, $subject, $body, $headers );
    }
  }
  </code></pre>
  
  <p>Here is an example of one of the errors:</p>
  
  <pre><code>PHP Notice:  Trying to get property 'user_email' of non-object
  </code></pre>
  
  <p>And finally, you can see where these are set
  <a href="https://i.stack.imgur.com/2MGC7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2MGC7.png" alt="enter image description here"></a></p>