code: def add_group(group, user=None):
      
      user = get_user(user)
  
      if user is None:
          raise ValueError("User '{}' not found".format(repr(user)))
  
      if isinstance(group, basestring):
          group = [group]
      elif isinstance(group, GroupData):
          group = [group]
  
      portal_groups = get_tool("portal_groups")
      for group in map(get_group, group):
          if group is None:
              continue
          portal_groups.addPrincipalToGroup(get_user_id(user), group.getId())
  
      return get_groups(user)
docs: Add the user to the group