To use an attribute in the frontend you have to do two things.
- add the attribute to the EAV
tell magento that the attribute should be used and is allowed to be saved by the customer. There are lots of attributes you don't want to be saved by the customer, for example created_at, updated_at or any account balance should not be editable by the customer.
All the attributes are saved in the different forms via
$customerForm = Mage::getModel('customer/form'); $customerForm->setFormCode('customer_account_create') ->setEntity($customer);
Have a look on the form codes. They are important to change the attributes. there are a few, like customer_account_edit, customer_account_create. Just check the code if the forms doesn't save your attribute, what is needed and how the form is named.
Add the attribute
<?php /* @var $installer Mage_Catalog_Model_Resource_Setup */ $installer = $this; $vCustomerEntityType = $installer->getEntityTypeId('customer'); $vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType); $vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId); $installer->startSetup(); $attributes = array( 'website' => 'Website', ); foreach ($attributes as $name => $attribute) { $installer->addAttribute( 'customer', $name, array( 'label' => $attribute, 'input' => 'text', 'type' => 'varchar', 'required' => 0, 'user_defined' => 1, ) ); $installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, $name, 0);
Make attribute usable in forms
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', $name); $oAttribute->setData( 'used_in_forms', array('customer_account_edit', 'customer_account_create', 'adminhtml_customer') ); $oAttribute->save(); } $installer->endSetup();