I want to get just telephone filed in my customer register page

 <?php if($this->getShowAddressFields()): ?>

I use above code But It's adding all the address fields to my registration page. I want only telephone number field from address section.

3 Answers 3


Add Telephone to customer registration,customer edit page etc. run following setup script from magento root.


$installer = new Mage_Customer_Model_Entity_Setup('core_setup');


$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);

$installer->addAttribute('customer', 'cust_telephone', array(
        'label' => 'Customer Telephone',
        'input' => 'text',
        'type'  => 'varchar',
        'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
        'required' => 0,
        'user_defined' => 1,

$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'mobile', 0);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'cust_telephone');
$oAttribute->setData('used_in_forms', array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'));


Run this Script, it will add attribute "cust_telephone" and now you can use this attribute in the register form, like this

<li class="fields">
    <div class="field">
        <label><em>*</em><?php echo $this->__('Customer Telephone') ?></label>
        <div class="input-box">
            <input type="text" name="cust_telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getCust_Telephone()) ?>" title="<?php echo $this->__('Customer Telephone') ?>" class="input-text" />

the code is tested, will work 100% ;)



  • thanks but i need to add data(number) to telephone field not create new field in magento database tables- its make problem to my extensions
    – majid
    Mar 1, 2018 at 19:55
  • without address i don't think telephone number get save Mar 6, 2018 at 9:57
  • this code created a new field.. tested in magento 1.9
    – Alam Zaib
    Sep 16, 2018 at 9:12

Go With the following path :


Get the telephone field outside the if condition. If you want to show only telephone field.

<?php if($this->getShowAddressFields()): ?>
  • when i use this code it show all address fields, i need just telephone field to show and save telephone correctly
    – majid
    Feb 27, 2018 at 13:42
  • this link will helps you. remove above xml from your file and get the telephone field outside the if condition. from \app\design\frontend\base\default\template\persistent\customer\form\register.phtml check here prnt.sc/ikfrbt Feb 27, 2018 at 14:01
  • tnks for answer but telephone number that i insert in register page doesnt save in database and show null!
    – majid
    Feb 27, 2018 at 14:25
  • did you got solution ?
    – Pawan
    Feb 27, 2018 at 17:05
  • when i move telephone filed befor if condition it doesnt save telephone in database- and if i use telephone filed in if condion and delete other fields it gave validation errors for (state,city, etc)
    – majid
    Feb 27, 2018 at 17:33

If you want to show the telephone number field and exclude all other address related fields, then the easy way would be add below code in register.phtml file wherever you need.

File: app/design/frontend/[package]/[theme]/template/customer/form/register.phtml

<div class="field">
    <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
    <div class="input-box">
        <input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />

This would be the easy choice in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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