Magento Admin – Add Custom Attributes in Customer Registration Form

attributescustomerregister

I wish to create new fields in the customer registration form. I just wanted to know whether there is any option to create it from Magento admin panel.

Kindly guide me as am new to magento.

Best Answer

No, There is no option to create it from admin. You will need to create custom script to create it. You can follow below module steps to create custom attribute.

app/code/local/Custom/Customerattribute/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Custom_Customerattribute>
            <version>0.1.0</version>
        </Custom_Customerattribute>
    </modules>
    <global>
        <resources>
            <customerattribute_setup>
                <setup>
                    <module>Custom_Customerattribute</module>
                    <class>Mage_Customer_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customerattribute_setup>
            <customerattribute_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </customerattribute_write>
            <customerattribute_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </customerattribute_read>
        </resources>
    </global>
</config> 

app/code/local/Custom/Customerattribute/sql/customerattribute_setup/mysql4-install-0.1.0.php

<?php
$installer = $this;
$installer->startSetup();


$installer->addAttribute("customer", "custom_attribute",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Custom Attribute",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => false,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "custom_attribute");


$used_in_forms=array();

$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
        $attribute->setData("used_in_forms", $used_in_forms)
        ->setData("is_used_for_customer_segment", true)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 1)
        ->setData("is_visible", 1)
        ->setData("sort_order", 100)
        ;
        $attribute->save();



$installer->endSetup();

And finally declare your module

app/etc/modules/Custom_Customerattribute.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Custom_Customerattribute>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Custom_Customerattribute>
  </modules>
</config>

You can change your attribute code and label as per your requirement.