1. Add new fields in config xml (app\code\core\Mage\Customer\etc\config.xml). If you create new module then you can add this xml block in module config xml file. Create new module is the best practice and recommended
<?xml version=”1.0″?>
<fieldsets>
<customer_account>
<prefix><create>1</create><update>1</update><name>1</name></prefix>
<firstname><create>1</create><update>1</update><name>1</name></firstname>
<middlename><create>1</create><update>1</update><name>1</name></middlename>
<lastname><create>1</create><update>1</update><name>1</name></lastname>
<suffix><create>1</create><update>1</update><name>1</name></suffix>
<email><create>1</create><update>1</update></email>
<password><create>1</create></password>
<confirmation><create>1</create></confirmation>
<dob><create>1</create><update>1</update></dob>
<taxvat><create>1</create><update>1</update></taxvat>
<gender><create>1</create><update>1</update></gender>
/* newly added field(s)*/
<occupation><create>1</create><update>1</update><name>1</name></occupation>
</customer_account>
</fieldsets>
2. In setup.php(app/code/core/mage/customer/module/entity/) add the folowing code in public function getDefaultEntities()
‘occupation’ => array(
‘label’ => ‘Occupation’,
‘required’ => false,
‘sort_order’ => 69,
),
3. Add these extra field(s) in your respective theme registration.phtml (app\design\frontend\…\…\template\customer\form\registration.phtml). Keep the field name same as you mentioned in config.xml
<div>
<label for=”occupation”><?php echo $this->__(‘Occupation’) ?></label><br/>
<input type=”text” name=”occupation” id=”occupation” value=”<?php echo $this->htmlEscape($this->getFormData()->getOccupation()) ?>” title=”<?php echo $this->__(‘Occupation’) ?>” />
</div>
4. To save extra data in database with customer registration process you have to add these extra field(s) as entity attribute in eav_attribute table. Here is sql script.
insert into `magento`.`eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`)
values(1, ‘occuption’, ”, ”, ‘varchar’, ”, ”, ‘select’, ‘Occuption’, ”, ”, 0, 0, ”, 0,”);
5. After this sql script run this query
INSERT INTO `magento`.`customer_eav_attribute` (`attribute_id`, `is_visible`, `is_visible_on_front`, `input_filter`, `lines_to_divide_multiline`, `min_text_length`, `max_text_length`) VALUES (‘last_insert_id’, ‘1’, ‘0’, ”, ‘0’, ‘0’, ‘0’);
Where last_insert_id IS attribute_id of last record insert by step 4 query.
5. Add these extra field(s) in your edit.phtml (app\design\frontend\…\…\template\customer\form\edit.phtml). Keep the field name same as you mentioned in config.xml
<div>
<label for=”occupation”><?php echo $this->__(‘Occupation’) ?></label><br/>
<input type=”text” name=”occupation” id=”occupation” value=”<?php echo $this->htmlEscape($this->getCustomer()->getOccupation()) ?>” title=”<?php echo $this->__(‘Occupation’) ?>” />
</div>
That’s all. Try and let me know if you face any complexity.
Like this you can add extra field(s) in any magento pages as well.