function blended_remove_team_member($team, $id_member)
{
    global $DB;
    $userid_leader = $team->leaderid;
    $members = blended_get_team_members($team->id);
    if (isset($members[$id_member])) {
        $deleted = groups_remove_member($team->id, $id_member);
        if ($userid_leader == $id_member) {
            // if removed user id the leader removes the leader
            blended_set_team_leaderid($team->id, null);
            $team->leaderid = null;
        }
    }
}
        }
        $members = array($USER->id => $USER);
        $teamid = blended_add_new_group($course->id, $name_team, $members, $groupingid);
        blended_set_team_leaderid($teamid, $USER->id);
        $a = new stdClass();
        $a->username = fullname($USER);
        $a->teamname = $name_team;
        echo $OUTPUT->notification(get_string('userenrolledtoteam', 'blended', $a));
    } else {
        if ($action == 'signup' && $blended->teammethod != TEAMS_BY_TEACHERS) {
            //Comprobar que:
            //-no esta en otro equipo
            //- que el tamaño no supere el tamaño maximo propuesto por el profesor
            $id_team = required_param('team', PARAM_INT);
            //id equipo
            $members = blended_get_team_members($id_team, $blended);
            if (count($members) >= $blended->nummembers || $grouping->maxmembers !== null && count($members) >= $grouping->maxmembers) {
                echo $OUTPUT->notification(get_string('teamisfull', 'blended'));
            } else {
                if (blended_enrol_user_to_team($id_team, $USER->id, $item, $blended)) {
                    $a = new stdClass();
                    $a->username = fullname($USER);
                    $a->teamname = blended_get_team($id_team)->name;
                    echo $OUTPUT->notification(get_string('userenrolledtoteam', 'blended', $a));
                }
            }
        } else {
            print_error('nopermissions', 'blended');
        }
    }
}