# Бесплатные способы автоматизации отправки приглашений на Discourse через WordPress (и другие платформы)

**URL:** <https://meta.discourse.org/t/free-ways-to-automate-sending-discoures-invite-emails-with-wordpress-and-other-platform/122097>\
**Category:** WordPress\
**Created:** [04.Июль.2019 13:08:57 UTC](https://meta.discourse.org/t/free-ways-to-automate-sending-discoures-invite-emails-with-wordpress-and-other-platform/122097 "2019-07-04T13:08:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Phuong\_SuSu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/phuong_susu/32/148042_2.png) [@Phuong\_SuSu](https://meta.discourse.org/u/Phuong_SuSu)\
**Post date:** [05.Июль.2019 16:28:21 UTC](https://meta.discourse.org/t/free-ways-to-automate-sending-discoures-invite-emails-with-wordpress-and-other-platform/122097/2 "2019-07-05T16:28:21Z")

</div>

Обновление: Этот код будет приглашать только одобренные комментарии, чтобы избежать приглашения спамеров.

```
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 ) {
  // пригласить пользователя
  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' => 'Спасибо. Ваш комментарий одобрен, и вы получили приглашение присоединиться к моему форуму.')
        )
  );  
 };
}
add_action('comment_unapproved_to_approved', 'invite_forum_from_approved_comment');

```

---

_[View the full topic](https://meta.discourse.org/t/free-ways-to-automate-sending-discoures-invite-emails-with-wordpress-and-other-platform/122097)._
