In Magento 2 , defaultly admin has to assign customer groups for all the user but I need to develop, user will select their role while register his/her account.
Magento 2 Customer Registration with Customer Group
customercustomer-groupmagento2
customercustomer-groupmagento2
In Magento 2 , defaultly admin has to assign customer groups for all the user but I need to develop, user will select their role while register his/her account.
Best Answer
1. Add your phtml to additional info block, by creating following file: /Nano/CommissionAgents/view/frontend/layout/customer_account_create.xml.
2. Now create phtml file : /Nano/CommissionAgents/view/frontend/templates/addcustomergroup.phtml
3. Create a Block to fetch all customer groups that we have to use in phtml. Create block file at (/Nano/CommissionAgents/Block/CustomerGroups.php)
4. Create an Observer for event "customer_register_success". For this create an events.xml in (/Nano/CommissionAgents/etc/frontend/events.xml)
5. Create observer class to save customer group after registration in file (/Nano/CommissionAgents/Observer/SaveCustomerGroupId.php)
6. Now try registering after: setup-upgrade, cache flush, static-content-deply and check. Hope you will find customer group in frontend and also be able to save that group (can be verified in backend).