Answers.Body: <p>Matt and I managed to work this out together. Seems like setting the <code>pending</code> and <code>unverifiedEmail</code> attributes on the userModel before saving the user does the trick.</p>
  
  <pre><code>$user = new UserModel();
  $user-&gt;pending = true;
  $user-&gt;unverifiedEmail = "username@domain.com";
  craft()-&gt;users-&gt;saveUser($user);
  </code></pre>
  
  <p>Edit: Might also want to look into another syntax that I noticed in <a href="https://craftcms.stackexchange.com/questions/1425/how-to-add-link-an-entry-to-an-object-using-php">this question</a>.</p>
  
  <pre><code>$user = new UserModel();
  $user-&gt;status = UserStatus::Pending;
  $user-&gt;email = "username@domain.com";
  craft()-&gt;users-&gt;saveUser($user);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-03T17:47:36.967Z
Answers.LastActivityDate: 2015-04-03T18:01:33.880Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I'm writing a plugin to create users. The problem I'm having is when I create them Craft is automatically setting the user as "active". I want them to be "inactive" so that I can then send a verification email. I've look through the code and there appears to be no way to Create a user using <strong>craft()->users->saveUser($user)</strong> without having them always be active. </p>
  
  <p>In the admin panel I do have the "Verify email addresses?" option checked.</p>
  
  <p>Please help!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T16:01:32.583Z
Comments.Text: Just beacuse they are active does not mean that they can login yet. I believe that they still have to go through the email verification process to set their password, etc. Setting them as inactive would mean that they could never login or verify their email address. Is there some other reason you want them to be inactive?
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T16:07:34.263Z
Comments.Text: I think rather the "inactive" I should've said "unverified". I don't want new users to be verified until they click the link in the verification email.
Comments.UserDisplayName: Matt V
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T16:22:41.367Z
Comments.Text: Not sure. But you might try setting the 'unverifiedEmail' property on the user model (vs 'email' property) before saving. Not sure if that alone will do it.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T16:26:28.860Z
Comments.Text: Fyi.. here is a list of all the [userModel attributes](http://buildwithcraft.com/classreference/models/UserModel#defineAttributes-detail) which might help. I see that there is also a 'pending' attribute which should probably be set to true, as well as the unverifiedEmail.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T16:42:58.523Z
Comments.Text: Ah! Yes! Thank you. I did see this earlier but it looks like "pending" and "unverifiedEmail" work together? Because I did try just setting "pending" to true and that did nothing. But setting both works.
Comments.UserDisplayName: Matt V
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T17:45:54.253Z
Comments.Text: Cool. Glad it worked.
Comments.UserDisplayName: Douglas McDonald
Tags: <plugin-development><users><user-profile>
Title: Creating users as inactive
ThreadText: # Creating users as inactive
  
  (Asked by: username_0 on 2015-04-03)
  
  I'm writing a plugin to create users. The problem I'm having is when I create them Craft is automatically setting the user as "active". I want them to be "inactive" so that I can then send a verification email. I've look through the code and there appears to be no way to Create a user using **craft()->users->saveUser($user)** without having them always be active.
  
  In the admin panel I do have the "Verify email addresses?" option checked.
  
  Please help!
  
  **Tags:** plugin-development, users, user-profile
  
  > **Comments:**
  > **username_1**: Just beacuse they are active does not mean that they can login yet. I believe that they still have to go through the email verification process to set their password, etc. Setting them as inactive would mean that they could never login or verify their email address. Is there some other reason you want them to be inactive?  
  > **username_0**: I think rather the "inactive" I should've said "unverified". I don't want new users to be verified until they click the link in the verification email.  
  > **username_1**: Not sure. But you might try setting the 'unverifiedEmail' property on the user model (vs 'email' property) before saving. Not sure if that alone will do it.  
  > **username_1**: Fyi.. here is a list of all the [userModel attributes](http://buildwithcraft.com/classreference/models/UserModel#defineAttributes-detail) which might help. I see that there is also a 'pending' attribute which should probably be set to true, as well as the unverifiedEmail.  
  > **username_0**: Ah! Yes! Thank you. I did see this earlier but it looks like "pending" and "unverifiedEmail" work together? Because I did try just setting "pending" to true and that did nothing. But setting both works.  
  > **username_1**: Cool. Glad it worked.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-03. Score: 2
  
  username_0 and I managed to work this out together. Seems like setting the `pending` and `unverifiedEmail` attributes on the userModel before saving the user does the trick.
  
  ```
  $user = new UserModel();
  $user->pending = true;
  $user->unverifiedEmail = "username@domain.com";
  craft()->users->saveUser($user);
  
  ```
  
  Edit: Might also want to look into another syntax that I noticed in [this question](https://craftcms.stackexchange.com/questions/1425/how-to-add-link-an-entry-to-an-object-using-php).
  
  ```
  $user = new UserModel();
  $user->status = UserStatus::Pending;
  $user->email = "username@domain.com";
  craft()->users->saveUser($user);
  
  ```
  
  
  ---
  
  