1

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.

Coppa
  • 394
  • 3
  • 7

1 Answers1

2

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 that address this particular need, but have a look. You could also contact someone through the 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. 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);
        };
    });
}
Douglas McDonald
  • 13,457
  • 24
  • 57