Add a User to a Group

@param string $userUri
@param core_kernel_classes_Resource $group
@return boolean
356315
public function addUser($userUri, core_kernel_classes_Resource $group) {
        $user = new \core_kernel_classes_Resource($userUri);
        return $user->setPropertyValue(new core_kernel_classes_Property(self::PROPERTY_MEMBERS_URI), $group);
    }
535725
public static function get_users_in_context(userlist $userlist) {
        $context = $userlist->get_context();

        if (!$context instanceof \context_course) {
            return;
        }

        static::get_group_members_in_context($userlist, '');
    }
1023431
public Response addUserToGroup(String username, String groupName) {
		return restClient.post("users/" + username + "/groups/"+ groupName, null,
				new HashMap<String, String>());
	}
336422
public function set_usergroup($user_id, $group_id)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $payload  = ['usergroup_id' => $group_id];
        $response = $this->exec_curl('/api/s/' . $this->site . '/upd/user/' . trim($user_id), $payload);

        return $this->process_response_boolean($response);
    }
557050
public function addGroup($group) {
    if (!$group->inArray((array) $this->groups)) {
      $this->groups[] = $group;
      return $this->groups;
    }
    return true;
  }
1363794
public function addUser(ServerUser $user)
    {
        if ($this->users->contains($user) === false) {
            $user->setServer($this);
            $this->users->add($user);
        }

        return $this;
    }
365816
private function addUserGroup(UserInterface $user, $userGroupData)
    {
        $group = $this->groupRepository->findGroupById($userGroupData['group']['id']);

        if (!$group) {
            throw new EntityNotFoundException($this->groupRepository->getClassName(), $userGroupData['group']['id']);
        }

        $userGroup = new UserGroup();
        $userGroup->setUser($user);
        $userGroup->setGroup($group);
        $userGroup->setLocale(json_encode($userGroupData['locales']));
        $this->em->persist($userGroup);

        $user->addUserGroup($userGroup);

        return true;
    }
1152896
public function addGroup(ChildGroup $group)
    {
        if ($this->collGroups === null) {
            $this->initGroups();
        }

        if (!$this->getGroups()->contains($group)) {
            // only add it if the **same** object is not already associated
            $this->collGroups->push($group);
            $this->doAddGroup($group);
        }

        return $this;
    }
686761
public function addUser(User $user): bool
	{
		if(!$this->isPersisted)
		{
			throw new LogicException('You can only add a user to a group that exist in the database.');
		}

		if(!$user->isPersisted())
		{
			throw new LogicException('You can only add a user that exist in the database to a group.');
		}

		return $this->users()->link($user);
	}
1141627
def add_user_to_group(self, GroupID, UserID):
        """"""
        # http://teampasswordmanager.com/docs/api-groups/#add_user
        log.info('Add User %s to Group %s' % (UserID, GroupID))
        self.put('groups/%s/add_user/%s.json' % (GroupID, UserID))
655122
public function userIsParticipant( eZUser $user )
    {
        /** @var eZCollaborationItemParticipantLink $participantLink */
        foreach ( $this->participantList() as $participantLink )
        {
            $participant = $participantLink->participant();

            if ( $participant instanceof eZUser )
            {
                if ( $participant->attribute( 'contentobject_id' ) == $user->attribute( 'contentobject_id' ) )
                {
                    return true;
                }
            }
            // user group
            else if ( $participant instanceof eZContentObject )
            {
                foreach ( $user->groups() as $userGroup )
                {
                    if ( $participant->attribute( 'id' ) == $userGroup->attribute( 'id' ) )
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
943462
public function addUser(\FOM\UserBundle\Entity\User $user)
    {
        $this->users[] = $user;
        $user->addGroup($this);
        return $this;
    }
347758
function addToGroup($group)
    {
        $this->_api->doRequest("PUT", "{$group->getBaseApiPath()}/contacts/{$this->id}");               
        $this->_group_ids_set[$group->id] = true;        
    }
715333
private function addGroup(MenuGroup $group)
    {
        if (!$this->hasGroup($group->getName())) {
            $this->groups[$group->getName()] = $group;
        }
    }
979885
public function userCanReachCenter(User $user, Center $center)
    {
        foreach ($user->getGroupCenters() as $groupCenter) {
            if ($center->getId() === $groupCenter->getCenter()->getId()) {
                
                return true;
            }
        }
        
        return false;
    }
1160088
public function addUsers(User ...$users)
    {
        foreach ($users as $user) {
            $this->getUsers()->add($user);
        }

        return $this;
    }
532162
public void addUser(String userName, String userRealm, char[] password, String... groups) {
      if (userName == null) {
         throw new IllegalArgumentException("userName is null");
      }
      if (userRealm == null) {
         throw new IllegalArgumentException("userRealm is null");
      }
      if (password == null) {
         throw new IllegalArgumentException("password is null");
      }
      final String canonUserRealm = userRealm.toLowerCase().trim();
      final String canonUserName = userName.toLowerCase().trim();
      synchronized (map) {
         Map<String, Entry> realmMap = map.get(canonUserRealm);
         if (realmMap == null) {
            realmMap = new HashMap<String, Entry>();
            map.put(canonUserRealm, realmMap);
         }
         realmMap.put(canonUserName, new Entry(canonUserName, canonUserRealm, password, groups != null ? groups : new String[0]));
      }
   }