Dynamically pull the correct email address from a match
<p>Here's my current function,</p>

<pre><code> class emailer {
  function notifyHeart($post_ID)  {
    $interests = get_user_meta(get_current_user_id(), 'interests');
    $post = get_post($post_ID);

    foreach($interests as $interest) {
      if(has_tag($interest, $post)) {
        $to = get_the_author_meta( 'user_email', get_current_user_id() );  
        $email = $to;
        mail($email, "An article about Heart", 'A new post has been published!');
        break;
      }
    }
  }
}
add_action('publish_post', array('emailer', 'notifyHeart'));
</code></pre>

<p>So far it only works with one user, the other user isn't receiving an email when there's a tag from post that match their interest.</p>

<p>Ideally, I would like to retrieve an email only when a user's $interest matches a tag from a post, then the appropriate email address will be selected and sent.</p>
