Answers.Body: <p><strong>Update to carlcs answer:</strong></p>
  
  <p>The new MailChimp Subscribe plugin sends an array as result instead of an object. So I had to go this way:</p>
  
  <pre><code>craft()-&gt;on('users.onActivateUser', function(Event $event) {
      $user = $event-&gt;params['user'];
  
      if (!$user-&gt;admin) {
          $result = craft()-&gt;mailchimpSubscribe-&gt;subscribe($user-&gt;email, '');
  
          if (!$result["success"]) {
              Craft::log('Couldn’d subscribe to MailChimp list: '.print_r([
                  'errorCode' =&gt; $result["errorCode"],
                  'message' =&gt; $result["message"],
              ], true), LogLevel::Error);
          }
      }
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-23T07:50:30.613Z
Answers.LastActivityDate: 2017-05-23T07:50:30.613Z
Answers.UserDisplayName: Marco
Answers.Body: <p>If it helps anyone else, full working code for this task as of 19/11/2019 in Craft 3:</p>
  
  <p>Using the <a href="https://github.com/aelvan/mailchimp-subscribe-craft/" rel="nofollow noreferrer">MailChimp Subscribe</a> and <a href="https://github.com/lindseydiloreto/craft-businesslogic" rel="nofollow noreferrer">Business Logic</a> plugins, place the following near top of <code>BusinessLogic.php</code>:</p>
  
  <pre><code>// Make sure we have relevant Craft bits for use
  use craft\services\Users;
  use craft\events\UserEvent;
  </code></pre>
  
  <p>Then place the below subscription code within your <code>public function init() {}</code>:</p>
  
  <pre><code>// Add new user to Mailchimp on account activation event
  Event::on(
    Users::class,
    Users::EVENT_AFTER_ACTIVATE_USER,
    function (UserEvent $event) {
  
      // get our user
      $user = $event-&gt;user;    
  
      // Grab easier reference to mailchimp-subscribe plugin
      $msPlugin = Craft::$app-&gt;plugins-&gt;getPlugin('mailchimp-subscribe');
  
      // Make sure plugin exists
      if ($msPlugin &amp;&amp; $msPlugin instanceof \aelvan\mailchimpsubscribe\MailchimpSubscribe) {
  
        $listID = 'XXXXXXXXXX'; // mailchimp audience ID
  
        // Example data
        $result = $msPlugin-&gt;mailchimpSubscribe-&gt;subscribe($user['email'], $listID, [
          'email_type' =&gt; 'html',
          'language' =&gt; 'en',
          'vip' =&gt; false,
          'tags' =&gt; false,
          'merge_fields' =&gt; [
            'FNAME' =&gt; $user['firstName'],
            'LNAME' =&gt; $user['lastName']
          ]
        ]);
  
        // Handle outcome
        if (!$result['success']) {
  
          // Do something if failed (like output error to logs)
  
        } else {
  
          // Do something else if success...
  
        }
      }
    }
  );
  
  </code></pre>
  
  <p>Thanks to all other contributors here - definitely got me moving in the right direction.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T01:48:24.893Z
Answers.LastActivityDate: 2019-11-19T01:48:24.893Z
Answers.UserDisplayName: iamkeir
Answers.Body: <p>Install the <a href="https://github.com/aelvan/mailchimp-subscribe-craft/" rel="nofollow noreferrer">MailChimp Subscribe</a> plugin and add the following <code>users.onActivateUser</code> event listener to your site’s <a href="https://github.com/lindseydiloreto/craft-businesslogic" rel="nofollow noreferrer">Business Logic</a> plugin.</p>
  
  <pre class="lang-php prettyprint-override"><code>craft()-&gt;on('users.onActivateUser', function(Event $event) {
      $user = $event-&gt;params['user'];
  
      if (!$user-&gt;admin) {
          $result = craft()-&gt;mailchimpSubscribe-&gt;subscribe($user-&gt;email, '');
  
          if (!$result['success']) {
              Craft::log('Couldn’d subscribe to MailChimp list: '.print_r([
                  'errorCode' =&gt; $result['errorCode'],
                  'message' =&gt; $result['message'],
              ], true), LogLevel::Error);
          }
      }
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-03T22:32:58.503Z
Answers.Text: Hi Calcs, this is interesting. But I am such a newbie that I have no clue where to put this?! Could you please tell me in which file of the business logic plugin I have to paste this? And where would any error messages show up? What happens if a user is already subscribed? Will Mailchimp still send activation Emails? Could you add a Name as well?
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-04T21:30:48.653Z
Answers.Text: You’d add that event listener to your plugin main class (BusinessLogic.php) `init()` method, @outline4. For your other questions please refer to the Mailchimp plugin documentation or ask a new question here using the tag plugin-mailchimp.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-04T21:35:13.660Z
Answers.Text: Error messages would be logged to your craft.log file with the above code, but you can do whatever you want in the case of `$result->success` returning a false value.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-07T15:52:30.657Z
Answers.Text: Thanks.. Man... I can't find a BusinessLogic.php file, nor an init() method... Gosh... I feel so dumb... All I see is these 4 files: BusinessLogicPlugin.php, BusinessLogicController.php, BusinessLogicService.php, BusinessLogicVariable.php... and in them I can't find any init() stuff... Could you please retry to help me? I'm such a dushbag ;(
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-07T23:35:23.657Z
Answers.Text: Sorry I meant the BusinessLogicPlugin.php file, create that method there @outline4
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-05T10:53:02.447Z
Answers.LastActivityDate: 2017-06-04T21:36:37.920Z
Answers.LastEditDate: 2017-06-04T21:36:37.920Z
Answers.UserDisplayName: carlcs
Body: <p>I would like to automatically subscribe all newly registered users to a MailChimp mailing list.</p>
  
Tags: <users><emails>
Title: Automatically subscribe users to MailChimp list?
ThreadText: # Automatically subscribe users to MailChimp list?
  
  (Asked by: username_0 on 2016-05-05)
  
  I would like to automatically subscribe all newly registered users to a MailChimp mailing list.
  
  **Tags:** users, emails
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2016-05-05. Score: 5 | Accepted answer
  
  Install the [MailChimp Subscribe](https://github.com/aelvan/mailchimp-subscribe-craft/) plugin and add the following `users.onActivateUser` event listener to your site’s [Business Logic](https://github.com/lindseydiloreto/craft-businesslogic) plugin.
  
  ```php
  craft()->on('users.onActivateUser', function(Event $event) {
      $user = $event->params['user'];
  
      if (!$user->admin) {
          $result = craft()->mailchimpSubscribe->subscribe($user->email, '');
  
          if (!$result['success']) {
              Craft::log('Couldn’d subscribe to MailChimp list: '.print_r([
                  'errorCode' => $result['errorCode'],
                  'message' => $result['message'],
              ], true), LogLevel::Error);
          }
      }
  });
  
  ```
  
  > **Comments:**
  > **username_3**: Hi Calcs, this is interesting. But I am such a newbie that I have no clue where to put this?! Could you please tell me in which file of the business logic plugin I have to paste this? And where would any error messages show up? What happens if a user is already subscribed? Will Mailchimp still send activation Emails? Could you add a Name as well?  
  > **username_0**: You’d add that event listener to your plugin main class (BusinessLogic.php) `init()` method, @username_3. For your other questions please refer to the Mailchimp plugin documentation or ask a new question here using the tag plugin-mailchimp.  
  > **username_0**: Error messages would be logged to your craft.log file with the above code, but you can do whatever you want in the case of `$result->success` returning a false value.  
  > **username_3**: Thanks.. Man... I can't find a BusinessLogic.php file, nor an init() method... Gosh... I feel so dumb... All I see is these 4 files: BusinessLogicPlugin.php, BusinessLogicController.php, BusinessLogicService.php, BusinessLogicVariable.php... and in them I can't find any init() stuff... Could you please retry to help me? I'm such a dushbag ;(  
  > **username_0**: Sorry I meant the BusinessLogicPlugin.php file, create that method there @username_3  
  
  ---
  
  ### Answer by username_1 on 2017-05-23. Score: 1
  
  **Update to username_0 answer:**
  
  The new MailChimp Subscribe plugin sends an array as result instead of an object. So I had to go this way:
  
  ```
  craft()->on('users.onActivateUser', function(Event $event) {
      $user = $event->params['user'];
  
      if (!$user->admin) {
          $result = craft()->mailchimpSubscribe->subscribe($user->email, '');
  
          if (!$result["success"]) {
              Craft::log('Couldn’d subscribe to MailChimp list: '.print_r([
                  'errorCode' => $result["errorCode"],
                  'message' => $result["message"],
              ], true), LogLevel::Error);
          }
      }
  });
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2019-11-19. Score: 1
  
  If it helps anyone else, full working code for this task as of 19/11/2019 in Craft 3:
  
  Using the [MailChimp Subscribe](https://github.com/aelvan/mailchimp-subscribe-craft/) and [Business Logic](https://github.com/lindseydiloreto/craft-businesslogic) plugins, place the following near top of `BusinessLogic.php`:
  
  ```
  // Make sure we have relevant Craft bits for use
  use craft\services\Users;
  use craft\events\UserEvent;
  
  ```
  
  Then place the below subscription code within your `public function init() {}`:
  
  ```
  // Add new user to Mailchimp on account activation event
  Event::on(
    Users::class,
    Users::EVENT_AFTER_ACTIVATE_USER,
    function (UserEvent $event) {
  
      // get our user
      $user = $event->user;    
  
      // Grab easier reference to mailchimp-subscribe plugin
      $msPlugin = Craft::$app->plugins->getPlugin('mailchimp-subscribe');
  
      // Make sure plugin exists
      if ($msPlugin && $msPlugin instanceof \aelvan\mailchimpsubscribe\MailchimpSubscribe) {
  
        $listID = 'XXXXXXXXXX'; // mailchimp audience ID
  
        // Example data
        $result = $msPlugin->mailchimpSubscribe->subscribe($user['email'], $listID, [
          'email_type' => 'html',
          'language' => 'en',
          'vip' => false,
          'tags' => false,
          'merge_fields' => [
            'FNAME' => $user['firstName'],
            'LNAME' => $user['lastName']
          ]
        ]);
  
        // Handle outcome
        if (!$result['success']) {
  
          // Do something if failed (like output error to logs)
  
        } else {
  
          // Do something else if success...
  
        }
      }
    }
  );
  
  ```
  
  Thanks to all other contributors here - definitely got me moving in the right direction.
  
  
  ---
  
  