1

I have come across a scenario where I need an event like "onAssignUserToGroup". This is purely for a client request and to modify functionality in the backend CP for my plugin, but this is the second time the need for something like this has arisen in the past one month. I have created the event in the userGroups service for now but it will be overridden by updates hence I would appreciate it if something like this was added to the official craft codebase. If that is not possible then let me know if there is another way to get something similar.

In my craft/app/UserGroupsService.php:

public function assignUserToGroups($userId, $groupIds = null)
{
    craft()->db->createCommand()
        ->delete('usergroups_users', array('userId' => $userId));

    if ($groupIds)
    {
        if (!is_array($groupIds))
        {
            $groupIds = array($groupIds);
        }

        foreach ($groupIds as $groupId)
        {
            $values[] = array($groupId, $userId);
        }

        craft()->db->createCommand()->insertAll('usergroups_users', array('groupId', 'userId'), $values);

        *// Custom event
        $this->onAssignUserToGroup(new Event($this, array(
            'userId'   => $userId,
            'groupIds' => $groupIds
        )));*
    }

    return true;
}

That is partly what I have done for now.