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
made to work :), thanks
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
Works perfect on 1.7.0.2. I also modified template/persistent/customer/form/register.phtml instead of template/customer/form/register.phtm
Thanks!
Magento Experts Developers developers are really impressed.
Magento Expert Developers great work very impressive.
This is not working in magento 1.8. Customer group not saved in db. Urgent please help me.
Saved correctly in db but not rendered in backend.
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
Post a Comment