title: Magento: Select Customer Group at Registration
body: <p>Trying to add a <strong>group_id</strong> radio button set in <strong>Magento Pro v1.11</strong></p>
  
  <p>Following along with <br>
  <a href="http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html">http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html</a> and<br>
  <a href="http://developersindia.info/magento/magento-override-frontend-controller.html">http://developersindia.info/magento/magento-override-frontend-controller.html</a>,<br> which is working to a point, but the group_id is not getting written to the db.</p>
  
  <p>my module, thus far:</p>
  
  <p>Directory Structure</p>
  
  <pre><code>app/code/local
  - WACI
  -- Customer
  --- controllers
  ---- AccountController.php
  --- etc
  ---- config.xml
  </code></pre>
  
  <p><br><br></p>
  
  <p><strong>config.xml</strong></p>
  
  <pre><code>&lt;config&gt;
      &lt;modules&gt;
          &lt;WACI_Customer&gt;
              &lt;version&gt;0.1.0&lt;/version&gt;
          &lt;/WACI_Customer&gt;
      &lt;/modules&gt;
      &lt;global&gt;
          &lt;fieldsets&gt;
              &lt;customer_account&gt;
                  &lt;group_id&gt;&lt;create&gt;1&lt;/create&gt;&lt;/group_id&gt;
              &lt;/customer_account&gt;
          &lt;/fieldsets&gt;
      &lt;/global&gt;
      &lt;frontend&gt;
          &lt;routers&gt;
              &lt;customer&gt;
                  &lt;args&gt;
                      &lt;modules&gt;
                          &lt;WACI_Customer before="Mage_Customer_AccountController"&gt;
                              WACI_Customer
                          &lt;/WACI_Customer&gt;
                      &lt;/modules&gt;
                  &lt;/args&gt;
              &lt;/customer&gt;
          &lt;/routers&gt;
      &lt;/frontend&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p><br><br></p>
  
  <p><strong>AccountController.php</strong></p>
  
  <pre><code>&lt;?php
  /**
   *Customer account controller
   *
   * @package     WACI_Customer
   */
  
  require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
  
  class WACI_Customer_AccountController extends Mage_Customer_AccountController
  {
  
      /**
      * Create customer account action
      */
      public function createPostAction()
      {
  
  // contents of createPostAction(), with some extra logic
  
              /**
               * Initialize customer group id
               */
  
              /* catch groupid at account creation */
  
              if($this-&gt;getRequest()-&gt;getPost('group_id')){ 
                  $customer-&gt;setGroupId($this-&gt;getRequest()-&gt;getPost('group_id'));
              } else {
                  $customer-&gt;getGroupId(); 
              } 
  
  
  
   // rest of method
  
      }
  
  }
  </code></pre>
  
  <p><br><br><br></p>
  
  <p><strong>theme../persistent/customer/form/register.phtml</strong></p>
  
  <pre><code>&lt;div class="input-box"&gt;
      &lt;label for="group_id"&gt;&lt;?php echo $this-&gt;__('Select your customer group') ?&gt;&lt;/label&gt;&lt;br /&gt;
      &lt;?php 
          $groups = Mage::helper('customer')-&gt;getGroups()-&gt;toOptionArray();
          foreach ($groups as $group){
              echo '&lt;input type="radio" name="group_id" value="'.$group['value'].'" class="validate-radio" &gt;'.$group['label'].'&lt;/input&gt;&lt;br/&gt;';
          }
      ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So, the radio buttons with the groups show up fine at registration, but the data isn't being written to the db, as group still shows as general in the <code>admin/manage customers</code></p>
  
  <ul>
  <li>I don't really want to modify core files, as the article describes, </li>
  <li>I'm not certain that I'm properly overwriting the mage
  <code>accountController</code> class (maybe theres a better way to do this?)</li>
  </ul>
  
  <p><strong>What am I mucking up?</strong></p>