Answers.Body: <p>You can programmatically trigger a notification email using the Sprout Email service layer. Notification Emails are sent via the <code>SproutEmail_DefaultMailerService</code> using the <code>sendNotification()</code> method:</p>
  
  <pre><code>craft()-&gt;sproutEmail_defaultMailer-&gt;sendNotification($campaign, $object);
  </code></pre>
  
  <ul>
  <li><code>$campaign</code> needs to be a <code>SproutEmail_CampaignModel</code></li>
  <li><code>$object</code>, in your case, would be the Craft <code>UserModel</code> (and more generally is any object that you want to make available to your email templates</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-24T02:22:37.060Z
Answers.Text: Will this attempt to send multiple emails if we set the trigger as "When a new user is created" ?
Answers.UserDisplayName: Fox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-24T02:36:53.817Z
Answers.Text: Options are checked when an event is triggered, and if they pass, then a notification is sent. This method just sends the notification directly, and won't check any of your options - assuming you are using it somewhere in your code where you know that the conditions you want to meet are valid.
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-24T01:42:42.213Z
Answers.LastActivityDate: 2016-06-24T01:42:42.213Z
Answers.UserDisplayName: Ben Parizek
Answers.Body: <p>I don't think this is a bug. If you are saying that you are using a custom plugin on creating a user you will have to define an on onSaveUser event after the save user script.</p>
  
  <p>E.g.</p>
  
  <pre><code>craft()-&gt;users-&gt;onSaveUser(new Event($this, array(
      'user'      =&gt; $user,
      'isNewUser' =&gt; $isNewUser
  )));
  </code></pre>
  
  <p>Sprout Email uses Craft events to trigger the notification.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-06T10:14:43.773Z
Answers.LastActivityDate: 2016-07-06T15:59:39.367Z
Answers.LastEditDate: 2016-07-06T15:59:39.367Z
Answers.UserDisplayName: Dale Ramirez
Body: <p>I am trying to send custom welcome emails to custom user groups but Sprout email is attempting to send the notification before the user group is created which means the email isn’t sending. The log just outputs that the user doesn't belong to any user group.</p>
  
  <p>Note: We are using a custom plugin to create the user and trigger a set your password email which could be the problem, is there a way to hook into sprout email so we can trigger the send from our plugin?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T01:43:10.560Z
Comments.Text: What event are you using as a trigger?
Comments.UserDisplayName: Ben Parizek
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T02:01:43.320Z
Comments.Text: @BenParizek we are using "When a new user is created" and just specifying that it belongs to a specific user group. If I check "all" then it sends, but if I specify a particular group it doesn't.
Comments.UserDisplayName: Fox
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T02:39:11.127Z
Comments.Text: This may be a bug or something else at play. I've answered the how to send a notification programmatically below, which may help if your situation is a bit more complex and you need to manually manage when the notification is triggered in your workflow. I'll add the question of why this doesn't work via the event to our list to look into and see if we can recreate it locally.
Comments.UserDisplayName: Ben Parizek
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T02:44:59.280Z
Comments.Text: Awesome thanks! We'll give your suggestion below a whirl and update with the outcome!
Comments.UserDisplayName: Fox
Tags: <plugin-sproutemail>
Title: Trigger sent before user is added in user group so no email is sent
ThreadText: # Trigger sent before user is added in user group so no email is sent
  
  (Asked by: username_0 on 2016-06-24)
  
  I am trying to send custom welcome emails to custom user groups but Sprout email is attempting to send the notification before the user group is created which means the email isn’t sending. The log just outputs that the user doesn't belong to any user group.
  
  Note: We are using a custom plugin to create the user and trigger a set your password email which could be the problem, is there a way to hook into sprout email so we can trigger the send from our plugin?
  
  **Tags:** plugin-sproutemail
  
  > **Comments:**
  > **username_1**: What event are you using as a trigger?  
  > **username_0**: @username_1 we are using "When a new user is created" and just specifying that it belongs to a specific user group. If I check "all" then it sends, but if I specify a particular group it doesn't.  
  > **username_1**: This may be a bug or something else at play. I've answered the how to send a notification programmatically below, which may help if your situation is a bit more complex and you need to manually manage when the notification is triggered in your workflow. I'll add the question of why this doesn't work via the event to our list to look into and see if we can recreate it locally.  
  > **username_0**: Awesome thanks! We'll give your suggestion below a whirl and update with the outcome!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-06-24. Score: 1
  
  You can programmatically trigger a notification email using the Sprout Email service layer. Notification Emails are sent via the `SproutEmail_DefaultMailerService` using the `sendNotification()` method:
  
  ```
  craft()->sproutEmail_defaultMailer->sendNotification($campaign, $object);
  
  ```
  
  * `$campaign` needs to be a `SproutEmail_CampaignModel`
  * `$object`, in your case, would be the Craft `UserModel` (and more generally is any object that you want to make available to your email templates
  
  > **Comments:**
  > **username_0**: Will this attempt to send multiple emails if we set the trigger as "When a new user is created" ?  
  > **username_1**: Options are checked when an event is triggered, and if they pass, then a notification is sent. This method just sends the notification directly, and won't check any of your options - assuming you are using it somewhere in your code where you know that the conditions you want to meet are valid.  
  
  ---
  
  ### Answer by username_2 on 2016-07-06. Score: 1
  
  I don't think this is a bug. If you are saying that you are using a custom plugin on creating a user you will have to define an on onSaveUser event after the save user script.
  
  E.g.
  
  ```
  craft()->users->onSaveUser(new Event($this, array(
      'user'      => $user,
      'isNewUser' => $isNewUser
  )));
  
  ```
  
  Sprout Email uses Craft events to trigger the notification.
  
  
  ---
  
  