How to add customer group in registration form in Magento 1.7.2

Make a copy of config.xml from app > code > core > Mage > Customer > etc > config.xml and add the following line of code into the customer account fieldset and save it to app > code >local>config.xml and in this file add the following line of code into the customer account fieldset:



<fieldsets>
<customer_account>
............
<group_id><create>1</create><update>1</update></group_id>
...........
</customer_account>
</fieldsets>


add code to the frontend of the store, in the registration form. Open template/customer/form/register.phtml and add the following code somewhere in the form:


<div class="input-box">
<label for="group_id"><?php echo $this->__('Group') ?><span class="required">*</span></label><br/>
<select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" class="validate-group required-entry input-text" />
<?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>


also change some code in 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(); } 

9 comments:

not workin

November 19, 2013 at 9:11 PM comment-delete

made to work :), thanks

November 20, 2013 at 12:47 AM comment-delete

Thank you very much. Very helpful. Only change was that instead of template/customer/form/register.phtml I updated template/persistent/customer/form/register.phtml

January 12, 2014 at 8:40 PM comment-delete

Works perfect on 1.7.0.2. I also modified template/persistent/customer/form/register.phtml instead of template/customer/form/register.phtm

Thanks!

June 12, 2014 at 8:35 AM comment-delete

Magento Experts Developers developers are really impressed.

July 1, 2014 at 5:05 AM comment-delete

Magento Expert Developers great work very impressive.

July 22, 2014 at 4:29 PM comment-delete

This is not working in magento 1.8. Customer group not saved in db. Urgent please help me.

July 30, 2014 at 11:43 PM comment-delete

Saved correctly in db but not rendered in backend.

July 31, 2014 at 12:23 AM comment-delete

This is not working in magento 1.8.1 Customer group not saved in db. Urgent please help me. sir but frond end nice to work please help me

September 25, 2014 at 3:39 AM comment-delete

Post a Comment