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
Create module folder in app/code/local/Rifki/MembershipGroup/
then create config.xml in app/code/local/Rifki/MembershipGroup/etc/config.xml
create event observer in app/code/local/Rifki/MembershipGroup/Model/Observer.php
See more about Magento event observer https://magento2.atlassian.net/wiki/display/m1wiki/Using+the+Event-Observer+Method+in+Magento+1.x