Here’s what I have so far..
class emailer {
function notifyHeart($post_ID) {
$interests = get_user_meta( get_current_user_id(), 'interests', TRUE );
$to = the_author_meta( 'user_email', get_current_user_id() );
if(has_tag($interests[0])) {
$email = $to;
mail($email, "An article about Heart",
'A new post has been published about heart.');
return $post_ID;
}
}
}
add_action('publish_post', array('emailer', 'notifyHeart'));
What I need to do now, before actually sending the email, I need something that checks if the user has an $interest and if so, send them an email. Any help with this?
Here’s a reworked example. It retrieves all the tags you have in database as meta, checks each of them & if it matches the one in that post’s id, it will send the mail & break out of the loop.