It sounds like it’s not working because you’re hooking into comment_post
, which is when the comment is created If you change the status of the comment, the comment already exists, and therefore no email is generated.
There is a comment status change hook: comment_{$old_status}_to_{$new_status}
.
It fires anytime a comment’s status changes from one specified status to another.
So you might try something like this instead:
function send_comment_email_notification($comment) {
$master_email = get_post_meta( $comment->comment_post_ID, 'email_custom', true);
if( isset( $master_email ) && is_email( $master_email ) ) {
$message="New comment";
add_filter( 'wp_mail_content_type', create_function( '', 'return "text/html";' ) );
wp_mail( $master_email, 'New comment', $comment->comment_content );
}
}
add_action('comment_spam_to_approved', 'send_comment_email_notification');
Documentation here: https://developer.wordpress.org/reference/hooks/comment_old_status_to_new_status/