public function add_user_to_group($user, $groupid) {
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!$group) {
            return false;
        }
        return groups_add_member($group->id, $user->id);
    }
public function add_user_to_group($user, $groupid) {
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!$group) {
            return false;
        }
        return groups_add_member($group->id, $user->id);
    }
public function add_user_to_group ( $ user , $ groupid ) { require_capability ( 'moodle/course:managegroups' , $ this -> context ) ; $ group = $ this -> get_group ( $ groupid ) ; if ( ! $ group ) { return false ; } return groups_add_member ( $ group -> id , $ user -> id ) ; }
Adds a user to a group

@param stdClass $user
@param int $groupid
@return bool
Adds a user to a group