Follow below step to add custom attribute in magento customer module…

Include below script some where in your template file and load it once…

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'customcode', array(
 'label'        => 'customcode',
 'type'        => 'varchar',
 'visible'    => true,
 'required'    => false,
'sort_order' = > 10


After run it once, please remove the above code.
Remove cache and check customer adding area in backend.

For removing any custom attributes…run below code from some where in your loading templates


$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->removeAttribute('customer', 'customcode');


Once run , please remove above code…
Let me know your comments….

  3 Responses to “Simple way to add and delete custom customer attributes in magento”

  1. Hi,

    with Magento 1.6.1 is used the Class “Mage_Customer_Model_Resource_Setup” for the setup script. I tested ur example too, but the sort_order won’t work. In my case i use the following:

    /* @var $installer Mage_Customer_Model_Resource_Setup */
    $installer = $this;

    $this->addAttribute(‘customer’, ‘xxxx’, array(
    ‘label’ => ‘Xxxx’,
    ‘type’ => ‘varchar’,
    ‘required’ => 0,
    ‘position’ => 111,

  2. Thank You!!!

 Leave a Reply




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2014 Developers Corner Suffusion theme by Sayontan Sinha