Answers.Body: <p>Since you're bypassing Craft's own <a href="http://buildwithcraft.com/classreference/controllers/UsersController#actionSaveUser-detail" rel="nofollow">UsersController->actionSaveUser()</a>, you'll need to replicate a bit more of its functionality in order for it to work like you're wanting.</p>
  
  <p>First you'll want to make sure that "Require Email Verification" is checked under <code>Settings-&gt;Users-&gt;Settings</code> in the control panel.</p>
  
  <p>Then your <code>UserModel</code> will also need to set a few more things:</p>
  
  <pre><code>$user-&gt;unverifiedEmail = $email;
  $user-&gt;pending = true;
  </code></pre>
  
  <p>Completely untested, but that should do it.</p>
  
  <p>I highly recommend looking over Craft's default actionSaveUser implementation as there are many permissions/security guards in place for public registration that you should probably consider as well.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-14T09:19:10.203Z
Answers.Text: Cheers @bradbell It works well. Will definitely look over the default actionSaveUser.
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-13T20:59:34.470Z
Answers.LastActivityDate: 2015-10-13T20:59:34.470Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've built a plugin that does some work before saving the user from the standard Registration Form. My only issue is it does not fire the activation email which I added in. But it lets the user login without verification, so I'd like to know what I'm missing as I thought if I <code>use craft()-&gt;users-&gt;saveUser()</code> it automatically deals with this for new users. My code is as follows I think I may be missing something from the model?</p>
  
  <pre><code>$newUser = new UserModel();
  $newUser-&gt;username = $username;
  $newUser-&gt;email = $email;
  $newUser-&gt;newPassword = $password;
  
  $success = craft()-&gt;users-&gt;saveUser($newUser);
  
  if ($success)
      {
          // Code added to send email
          craft()-&gt;users-&gt;sendActivationEmail($newUser);
  
          $this-&gt;redirectToPostedUrl($newUser);
      }
  </code></pre>
  
Tags: <plugin-development><users><plugins><registration>
Title: New user validates without confirming email
ThreadText: # New user validates without confirming email
  
  (Asked by: username_0 on 2015-10-13)
  
  I've built a plugin that does some work before saving the user from the standard Registration Form. My only issue is it does not fire the activation email which I added in. But it lets the user login without verification, so I'd like to know what I'm missing as I thought if I `use craft()->users->saveUser()` it automatically deals with this for new users. My code is as follows I think I may be missing something from the model?
  
  ```
  $newUser = new UserModel();
  $newUser->username = $username;
  $newUser->email = $email;
  $newUser->newPassword = $password;
  
  $success = craft()->users->saveUser($newUser);
  
  if ($success)
      {
          // Code added to send email
          craft()->users->sendActivationEmail($newUser);
  
          $this->redirectToPostedUrl($newUser);
      }
  
  ```
  
  **Tags:** plugin-development, users, plugins, registration
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-13. Score: 1 | Accepted answer
  
  Since you're bypassing Craft's own [UsersController->actionSaveUser()](http://buildwithcraft.com/classreference/controllers/UsersController#actionSaveUser-detail), you'll need to replicate a bit more of its functionality in order for it to work like you're wanting.
  
  First you'll want to make sure that "Require Email Verification" is checked under `Settings->Users->Settings` in the control panel.
  
  Then your `UserModel` will also need to set a few more things:
  
  ```
  $user->unverifiedEmail = $email;
  $user->pending = true;
  
  ```
  
  Completely untested, but that should do it.
  
  I highly recommend looking over Craft's default actionSaveUser implementation as there are many permissions/security guards in place for public registration that you should probably consider as well.
  
  > **Comments:**
  > **username_0**: Cheers @username_1 It works well. Will definitely look over the default actionSaveUser.  
  
  ---
  
  