Use has_category()
to check if a post belongs to a certain category.
function email_friends( $post_ID )
{
if ( has_category( 'uncategorized', $post_ID )
{
$friends="[email protected], [email protected]";
wp_mail(
$friends,
"sally's blog updated",
'I just put something on my blog: ' . get_permalink( $post_ID )
);
}
}
add_action('publish_post', 'email_friends');
And you don’t need to return anything for an action handler.