Add customer in different group during registration in magento

Share

If you want to add customer in different group during registration than follow this instruction.

You need to change in two files.
1) app\design\frontend\[your theme]\default\template\customer\form\register.phtml
add following code in the page

<div>
   <label for="group_id"><?php echo $this->__('Group') ?><span>*</span></label>
   <select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" />
   <?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
   <?php foreach($groups as $group){ ?>
   <option value="<?php print $group['value'] ?>"><?php print $group['label'] ?></option>
   <?php } ?>
   </select>
</div>


2) app\code\core\Mage\Customer\controllers\AccountController.php

now replace $customer->getGroupId(); with

if($this->getRequest()->getPost('group_id'))
{
        $customer->setGroupId($this->getRequest()->getPost('group_id'));
}
else
{
        $customer->getGroupId();
}

This is good practise to override AccountController.php in your local directory

Comments are closed.