In this post, we will see how we can add custom attribute to customer model.

Let us say we want to add the attribute registration_city to customer model. For this, create a new file named add_custom.php on the root of your Magento installation.

Now add following code to it:

<?php
include('app/Mage.php');
Mage::app();

$installer = Mage::getResourceModel('customer/setup', 'customer_setup');
$installer->startSetup();

$installer->addAttribute('customer','registration_city', array(
    'label'             => 'Source State',
    'type'              => 'text',    //backend_type
    'input'             => 'text', //frontend_input
    'global'            =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible'           => true,
    'required'          => false,
    'default'           => '',
    'frontend'          => '',
    'unique'            => false,
    'note'              => ''
));

Mage::getSingleton('eav/config')
    ->getAttribute('customer', 'registration_city')
    ->setData('used_in_forms', array(
        'customer_account_create', 'customer_account_edit', 'customer_address_edit',
        'checkout_onepage_register', 'checkout_onepage_register_guest', 'checkout_onepage_billing_address',
        'adminhtml_customer','checkout_onepage_shipping_address','checkout_multishipping_register'
    ))
    ->save();
$installer->endSetup();

Execute the script on browser and the attribute should be added to customer model.