Answers.Body: <p>This is not currently possible through the CP (as far as I know anyway). You would need to write a plugin; and I haven't seen any plugins on <a href="http://straightupcraft.com/craft-plugins" rel="nofollow">straightupcraft</a> that address this particular need, but have a look. You could also contact someone through the <a href="http://straightupcraft.com/professionals" rel="nofollow">professionals</a> section that might be able to help.</p>
  
  <p>If you were to write your own plugin you might have a look at the documentation on <a href="http://buildwithcraft.com/docs/plugins/hooks-and-events" rel="nofollow">hooks and events</a>. In particular the <code>onSaveUser</code> event, where you could potentially force a user into a particular group, based on specific conditions that you establish.</p>
  
  <p>In your plugIns <code>init</code> function you could create a listener for the <code>onSaveUser</code> event.</p>
  
  <pre><code>public function init()
  {
      parent::init();
      craft()-&gt;on('users.saveUser', function(Event $event) 
      {
          $user = $event-&gt;params['user'];
          if ($allMyConditionsAreMet) 
          {
              if($allMyGroupConditionsAreMet) 
              {
                  $groupId = 1;
              } 
              else 
              {
                  $groupId = 2;
              }
              craft()-&gt;userGroups-&gt;assignUserToGroups($user-&gt;id, $groupId);
          };
      });
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-18T21:57:22.887Z
Answers.Text: Thanks for the help. It looks like a custom plugin will be the way to go in this case.
Answers.UserDisplayName: Coppa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-17T18:04:31.653Z
Answers.LastActivityDate: 2014-10-17T18:04:31.653Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I'm setting up a site for a charity with a national branch and several sub-chapters. I'd like users of a particular chapter to be able to add/modify users, but only within their chapter's user group. It seems like with the current structure of admin permissions, I'm only able to say whether or not a user can add/edit users, and not restrict that to a particular group.</p>
  
  <p>Is this possible and I'm just not seeing a setting somewhere? If not, does anyone know of a plugin that provides this functionality?</p>
  
  <p>Thanks.</p>
  
Tags: <users><user-groups>
Title: Restrict user editing permissions within a user's group?
ThreadText: # Restrict user editing permissions within a user's group?
  
  (Asked by: username_0 on 2014-10-17)
  
  I'm setting up a site for a charity with a national branch and several sub-chapters. I'd like users of a particular chapter to be able to add/modify users, but only within their chapter's user group. It seems like with the current structure of admin permissions, I'm only able to say whether or not a user can add/edit users, and not restrict that to a particular group.
  
  Is this possible and I'm just not seeing a setting somewhere? If not, does anyone know of a plugin that provides this functionality?
  
  Thanks.
  
  **Tags:** users, user-groups
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-17. Score: 2 | Accepted answer
  
  This is not currently possible through the CP (as far as I know anyway). You would need to write a plugin; and I haven't seen any plugins on [straightupcraft](http://straightupcraft.com/craft-plugins) that address this particular need, but have a look. You could also contact someone through the [professionals](http://straightupcraft.com/professionals) section that might be able to help.
  
  If you were to write your own plugin you might have a look at the documentation on [hooks and events](http://buildwithcraft.com/docs/plugins/hooks-and-events). In particular the `onSaveUser` event, where you could potentially force a user into a particular group, based on specific conditions that you establish.
  
  In your plugIns `init` function you could create a listener for the `onSaveUser` event.
  
  ```
  public function init()
  {
      parent::init();
      craft()->on('users.saveUser', function(Event $event) 
      {
          $user = $event->params['user'];
          if ($allMyConditionsAreMet) 
          {
              if($allMyGroupConditionsAreMet) 
              {
                  $groupId = 1;
              } 
              else 
              {
                  $groupId = 2;
              }
              craft()->userGroups->assignUserToGroups($user->id, $groupId);
          };
      });
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the help. It looks like a custom plugin will be the way to go in this case.  
  
  ---
  
  