First of all, you create customer group. let say you already create customer group with group_id 7. you can create customer group in backend Admin => Customer => Customer Group. my group_id is 7 & my group name Student.
You can do this by Magento event observer and also register Observer in config.xml
Register Module in app/etc/modules/Rifki_MembershipGroup.xml