Update: This code will invite only approved comment to prevent from inviting some spammers.
function invite_forum_from_approved_comment($comment_ID) {
$comment = get_comment( $comment_ID );
$comment_email = get_comment_author_email($comment);
$maybe_notify = ( '1' == $comment->comment_approved );
if ( $maybe_notify ) {
// invite user
wp_remote_post( 'https://forum.fususu.com/invites', array(
'method' => 'POST',
'headers' => array('Content-Type' => 'multipart/form-data',
'Api-key' => 'xxxxxxxxxxxxxxxxxxxx',
'Api-Username' => 'xxxx'),
'body' => array('email' => $comment_email,
'custom_message' => 'Thank you. Your comment is approved and you earned an invitation to join my forum.')
)
);
};
}
add_action('comment_unapproved_to_approved', 'invite_forum_from_approved_comment');