Answers.Body: <p>As far as I know there is no way to do this without a plugin. However, developing a plugin for this is not difficult. In your form you would want to add an additional drop-down, multi-select, or checkbox field with your groups listed. Then in your plugin, create a listener in your plugin's init method that listens for the <code>users.saveUser</code> event, and dynamically assigns the user to the selected groups based on the user's selection. For an example see this post explaining <a href="https://craftcms.stackexchange.com/questions/4259/is-it-possible-to-tell-if-a-user-was-registered-through-the-front-end-or-cp/4274#4274">how to respond to an onSaveUser event</a>, and this post on <a href="https://craftcms.stackexchange.com/questions/4197/restrict-user-editing-permissions-within-a-users-group/4202#4202">assigning groups dynamically</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T10:14:55.207Z
Answers.Text: Thanks for your answer. I was wondering apart from this if it's possible to just assign a user to a user group from the front-end registration form? This way I could just build multiple registration forms, each assigning users to their own group.
Answers.UserDisplayName: Hasco
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T14:41:12.477Z
Answers.Text: Unfortunately no. Without the aid of a plugin, its only possible to define a single default group for all public registrations.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T16:13:11.417Z
Answers.Text: I thought I should add: for securities sake it would be best not to just allow any group ID to be assigned (i.e. don't just assign the group id that is passed from the form blindly), but rather selectively assign the groups that you do want to allow. Otherwise an attacker might be able to make themselves admin.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T17:32:34.710Z
Answers.Text: I agree, so the attempt from my question is definitely a no go. In the meantime I wrote a plugin to solve my issue. Users are now able to select a group they want to sign up for in the registration form. I'll post it here as an answer.
Answers.UserDisplayName: Hasco
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T21:26:25.127Z
Answers.Text: What you have above could work, just check (i.e. if 1 then group 1; if 2 then group 2; if 3 then redirect to department of homeland security cyberattack division) :)
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T22:00:42.513Z
Answers.Text: Haha, what if I made 3 different forms which all have their own assigned user group, would that be more secure?
Answers.UserDisplayName: Hasco
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T01:04:14.260Z
Answers.Text: One form is fine. Just restrict what user groups they can be assigned to and your fine.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-10T16:29:40.070Z
Answers.LastActivityDate: 2014-11-10T16:29:40.070Z
Answers.LastEditDate: 2017-04-13T12:51:00.160Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>Is there a way to allow a registrant to choose a user group in the registration form?</p>
  
  <p>I tried using the following code but it didn't work:</p>
  
  <pre><code>&lt;input type="hidden" name="userGroups" value="3"&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-03T16:39:32.403Z
Comments.Text: If you're looking for a **Craft 3** solution, check out my answer in this ticket: https://craftcms.stackexchange.com/a/27926/4433
Comments.UserDisplayName: Ryan
Tags: <users><form><user-groups><registration>
Title: How can I get a user to choose in which group he registers using the User Registration Form
ThreadText: # How can I get a user to choose in which group he registers using the User Registration Form
  
  (Asked by: username_0 on 2014-11-10)
  
  Is there a way to allow a registrant to choose a user group in the registration form?
  
  I tried using the following code but it didn't work:
  
  ```
  <input type="hidden" name="userGroups" value="3">
  
  ```
  
  **Tags:** users, form, user-groups, registration
  
  > **Comments:**
  > **username_1**: If you're looking for a **Craft 3** solution, check out my answer in this ticket: https://craftcms.stackexchange.com/a/27926/4433  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-11-10. Score: 3 | Accepted answer
  
  As far as I know there is no way to do this without a plugin. However, developing a plugin for this is not difficult. In your form you would want to add an additional drop-down, multi-select, or checkbox field with your groups listed. Then in your plugin, create a listener in your plugin's init method that listens for the `users.saveUser` event, and dynamically assigns the user to the selected groups based on the user's selection. For an example see this post explaining [how to respond to an onSaveUser event](https://craftcms.stackexchange.com/questions/4259/is-it-possible-to-tell-if-a-user-was-registered-through-the-front-end-or-cp/4274#4274), and this post on [assigning groups dynamically](https://craftcms.stackexchange.com/questions/4197/restrict-user-editing-permissions-within-a-users-group/4202#4202).
  
  > **Comments:**
  > **username_0**: Thanks for your answer. I was wondering apart from this if it's possible to just assign a user to a user group from the front-end registration form? This way I could just build multiple registration forms, each assigning users to their own group.  
  > **username_2**: Unfortunately no. Without the aid of a plugin, its only possible to define a single default group for all public registrations.  
  > **username_2**: I thought I should add: for securities sake it would be best not to just allow any group ID to be assigned (i.e. don't just assign the group id that is passed from the form blindly), but rather selectively assign the groups that you do want to allow. Otherwise an attacker might be able to make themselves admin.  
  > **username_0**: I agree, so the attempt from my question is definitely a no go. In the meantime I wrote a plugin to solve my issue. Users are now able to select a group they want to sign up for in the registration form. I'll post it here as an answer.  
  > **username_2**: What you have above could work, just check (i.e. if 1 then group 1; if 2 then group 2; if 3 then redirect to department of homeland security cyberattack division) :)  
  > **username_0**: Haha, what if I made 3 different forms which all have their own assigned user group, would that be more secure?  
  > **username_2**: One form is fine. Just restrict what user groups they can be assigned to and your fine.  
  
  ---
  
  