3

I have followed every tutorial I have found and doesn't work. I am trying to add the customer groups on the customer registration page but its not working. I hope this question will help others also as all the previous questions based on this are too old. Please, check below my code:

app/code/core/mage/customer/etc/config.xml

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

app/code/core/mage/customer/controllers/AccountController.php

Replace this

$customer->getGroupId();

with

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

app/design/frontend/base/default/template/persistent/customer/form/register.phtml

<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>
2
  • For all who faces same issue after done all right way but still it not work then please follow the @Qaisar Satti answer below. Sep 6, 2016 at 7:33
  • As an alternative approach. Check the section Dynamic Handles second example ProxiBlue/GlobalHandle/blob/master/README.md
    – ProxiBlue
    Sep 6, 2016 at 12:28

1 Answer 1

2

there is no problem is your code you are editing the wrong phtml file. edit this file then changes will be shown.

template/persistent/customer/form/register.phtml
5
  • I have edited the template/persistent/customer/form/register.phtml but still group not show on the registration page Sep 6, 2016 at 6:30
  • 1
    @muditmehrotra did you edit the correct template enable template hint help.sweettoothrewards.com/article/… and make sure cache is disabled Sep 6, 2016 at 6:34
  • i tested the code it is working make sure you editing on right place Sep 6, 2016 at 6:38
  • Thanks alot it worked after enable the template path. Its because of the theme. Ghost theme manage its own register.phtml in persistent folder that's why changes done in app/design/frontend/base/default/template/persistent/customer/form/register.phtml was not working but now it show groups on registration page. Sep 6, 2016 at 7:11
  • can you please check my question. magento.stackexchange.com/questions/135180/… Sep 7, 2016 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.