7/07/2011

How to add group in register form

in magento 1.5+ go to the
app\design\frontend\base\default\template\customer\form\register.phtml
add following code in the page

<div class="input-box">

<label for="group_id" class="required"><?php echo $this->__('Group') ?><em>*</em></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>

<br /><p class="required" style="float:left;">Retailer group require admin authentication </p>

</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();
}

No comments:

Post a Comment