<p>Sprout Import for Craft 3 supports importing Users and assigning them to User Groups. See the <a href="https://sprout.barrelstrengthdesign.com/docs/import/users.html" rel="nofollow noreferrer">Users</a> page of documentation for more info.</p>

<p>To do so, you just need to assign the User Group ID to the <code>groups</code> attribute:</p>

<pre><code>[
  {
    "@model": "barrelstrength\\sproutimport\\importers\\elements\\User",
    "attributes": {
      "username": "username",
      "firstName": "First",
      "lastName": "Last",
      "email": "user@website.com",
      "pending": 1,
      "lastLoginDate": "2014-12-11 04:12:06",
      "dateCreated": "2014-04-09 12:04:04",
      "dateUpdated": "2015-04-04 06:04:08",
      "admin": "1",
      "groups": [1,2]
    }
  }
]
</code></pre>

<hr>

<p>LEGACY RESPONSE:</p>

<p>Sprout Import does not yet support importing to User Groups.</p>

<p>While we do hope to add this feature in the future, we currently don't have an ETA. Please feel free to reach out to us directly if you'd like to discuss custom development options to help get this feature implemented.</p>

<p>You can add comments to or follow this feature <a href="https://github.com/barrelstrength/craft-sprout-import/issues/17" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2017-11-13T20:19:52.227Z
2018-06-25T21:01:36.177Z
2018-06-25T21:01:36.177Z
Ben Parizek
<p>we are trying to import users into a specific group but cant figure out how the json should go. Currently we have:</p>

<pre class="lang-json prettyprint-override"><code>[
    {
        "@model": "User",
        "attributes": {
            "username": "name@example.com",
            "firstName": "john",
            "lastName": "smith",
            "email": "name@example.com",
            "pending": "0",
            "lastLoginDate": "2017-08-11 04:12:06",
            "dateCreated": "2017-11-06 12:04:04",
            "dateUpdated": "2017-11-06 12:04:04"
        },
        "content": {
            "fields": {
                "customField": "00000"
            }
        },
        "settings": {
            "groups": {
                "groupId": "1"
            }
        }
    }
]
</code></pre>

<p>We've tried several variations on settings, permissions, and putting groups under content and attributes but nothing has worked so far.</p>

CC BY-SA 3.0
2017-11-08T18:08:44.313Z
You could just create the user by yourself. It requires only about 15 lines of php code to solve your issue and takes only about 5 minutes. I have used sprout because I always made those things by myself so I could help you writing your own code if you like
Robin Schambach
CC BY-SA 3.0
2017-11-08T19:22:01.917Z
I have over 130,000 users to add so I need to do it this way to make it easier.
Chattervast
CC BY-SA 3.0
2017-11-08T19:30:11.263Z
There is no difference if you want to save 10 users or 10000 users your php code won't change just your import data. I just wanted to state that such import functions are really easy to create in craft/yii so - if no one else can answer your question - writing your own or letting others write it for you might be less time consuming and more flexible for you
Robin Schambach
CC BY-SA 3.0
2017-11-08T19:37:28.320Z
Thanks! We may go that route but I wanted to try this first since it is already available. Do you have a sample of the code to do what you are talking about?
Chattervast
CC BY-SA 3.0
2017-11-08T20:01:01.733Z
Not right now since I'm not in my office currently. I just copied the code from crafts userController, removed some conditions, changed the `populateModelFromPost()` (or something like that) line to the normal `populateModel` and used my own array that has exactly the same structure like the form in your cp - you just need to inspect the html. It took me about 10 minutes to create that import. To be honest I don't think sprout did something much more complicated. You could insert a `var_dump` into crafts userController and try to create the same structure in your array for sprout
Robin Schambach
<json><user-groups><plugin-sproutimport>
Assign User to Group While Importing on Sprout Imports
# Assign User to Group While Importing on Sprout Imports

(Asked by: username_0 on 2017-11-08)

we are trying to import users into a specific group but cant figure out how the json should go. Currently we have:
[
    {
        "@model": "User",
        "attributes": {
            "username": "name@example.com",
            "firstName": "john",
            "lastName": "smith",
            "email": "name@example.com",
            "pending": "0",
            "lastLoginDate": "2017-08-11 04:12:06",
            "dateCreated": "2017-11-06 12:04:04",
            "dateUpdated": "2017-11-06 12:04:04"
        },
        "content": {
            "fields": {
                "customField": "00000"
            }
        },
        "settings": {
            "groups": {
                "groupId": "1"
            }
        }
    }
]

We've tried several variations on settings, permissions, and putting groups under content and attributes but nothing has worked so far.

**Tags:** json, user-groups, plugin-sproutimport

> **Comments:**
> **username_1**: You could just create the user by yourself. It requires only about 15 lines of php code to solve your issue and takes only about 5 minutes. I have used sprout because I always made those things by myself so I could help you writing your own code if you like  
> **username_0**: I have over 130,000 users to add so I need to do it this way to make it easier.  
> **username_1**: There is no difference if you want to save 10 users or 10000 users your php code won't change just your import data. I just wanted to state that such import functions are really easy to create in craft/yii so - if no one else can answer your question - writing your own or letting others write it for you might be less time consuming and more flexible for you  
> **username_0**: Thanks! We may go that route but I wanted to try this first since it is already available. Do you have a sample of the code to do what you are talking about?  
> **username_1**: Not right now since I'm not in my office currently. I just copied the code from crafts userController, removed some conditions, changed the `populateModelFromPost()` (or something like that) line to the normal `populateModel` and used my own array that has exactly the same structure like the form in your cp - you just need to inspect the html. It took me about 10 minutes to create that import. To be honest I don't think sprout did something much more complicated. You could insert a `var_dump` into crafts userController and try to create the same structure in your array for sprout  

---

## 1 answers

### Answer by username_2 on 2017-11-13. Score: 1 | Accepted answer

Sprout Import for Craft 3 supports importing Users and assigning them to User Groups. See the Users page of documentation for more info.
To do so, you just need to assign the User Group ID to the groups attribute:
[
  {
    "@model": "barrelstrength\\sproutimport\\importers\\elements\\User",
    "attributes": {
      "username": "username",
      "firstName": "First",
      "lastName": "Last",
      "email": "user@website.com",
      "pending": 1,
      "lastLoginDate": "2014-12-11 04:12:06",
      "dateCreated": "2014-04-09 12:04:04",
      "dateUpdated": "2015-04-04 06:04:08",
      "admin": "1",
      "groups": [1,2]
    }
  }
]


LEGACY RESPONSE:
Sprout Import does not yet support importing to User Groups.
While we do hope to add this feature in the future, we currently don't have an ETA. Please feel free to reach out to us directly if you'd like to discuss custom development options to help get this feature implemented.
You can add comments to or follow this feature here.


---

