add Postcode text field on customer registration form in magento front end.

2 Answers 2


Here is simple example from Raye

To allow to publish an attribute in the register form and some others form page, you have to set that the attribute(s) is/are available to those forms.

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

/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');

$store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$attributes = $installer->getAdditionalAttributes();

foreach ($attributes as $attributeCode => $data) {
    $installer->addAttribute('customer', $attributeCode, $data);

    $attribute = $eavConfig->getAttribute('customer', $attributeCode);
    $attribute->setWebsite( (($store->getWebsite()) ? $store->getWebsite() : 0));

    if (false === ($attribute->getIsSystem() == 1 && $attribute->getIsVisible() == 0)) {
        $usedInForms = array(
        if (!empty($data['adminhtml_only'])) {
            $usedInForms = array('adminhtml_customer');
        } else {
            $usedInForms[] = 'adminhtml_customer';
        if (!empty($data['adminhtml_checkout'])) {
            $usedInForms[] = 'adminhtml_checkout';

        $attribute->setData('used_in_forms', $usedInForms);

Complete answer.

Hope this helps.


Add a new customer attribute Postcode, and then modify the file located at

app/design/frontend/base/default/template/persistent/customer/form/register.phtml and add

<div class="input-box">
 <label for="YourAttributeName"><?php echo $this->__('YourAttributeName') ?><span class="required">*</span></label><br />
 <input type="text" name="YourAttributeName" id="YourAttributeID" value="<?php echo $this->htmlEscape($this->getFormData()->getYourAttributeName()) ?>" title="<?php echo $this->__('YourAttributeName') ?>" class="required-entry input-text" />

I would advice you to copy the phtml file from base to your local theme, if you are using a different theme.

Not the answer you're looking for? Browse other questions tagged or ask your own question.