Filipe Ferminiano
Filipe Ferminiano

Reputation: 8791

Magento 1.7 - Remove fields from registration in /customer/account/create/

I want to remove fields from Registration (/customer/account/create/). How can I do this? is there some way without get into files of the store (e.g. hiding these fields)?

Upvotes: 2

Views: 9341

Answers (2)

Rafael Corrêa Gomes
Rafael Corrêa Gomes

Reputation: 1907

Somehow I got it to work. This is want I did and I request you to try it and check if it solves the issue.

  1. Open Magento DB and go to the table core_config_data.
  2. Search for the path - customer/address/middlename_show.
  3. Edit Value field for customer/address/middlename_show and change it to 1 . Generally, this will be 0 (zero) by default.
  4. Save the table.
  5. Clear Cache. Preferably delete the folder Cache and Session present in var folder.
  6. Login to Magento admin and go to the following location: System --> Configuration --> CUSTOMERS --> Customer Configuration
  7. Under "Name and Address Options" tab, now the option for "Show Middle Name (initial)" will be shown as "Yes".
  8. Change it to "No".
  9. Save Config and clear Cache.

Upvotes: 3

Anthony
Anthony

Reputation: 3218

You should update some fields in the DB.

For example. I need to remove last name from registration form. It's a requried field. So I created own module with sql update file to change field parameters:

upgrade-1.0.0.1-1.0.0.2.php

/* @var $installer Mage_Customer_Model_Entity_Setup */

$installer = $this;

$installer->startSetup();
// SELECT attribute_id, entity_type_id FROM eav_attribute where attribute_code = 'lastname'
// SELECT * FROM customer_eav_attribute where attribute_id in (SELECT attribute_id FROM eav_attribute where attribute_code = 'lastname')
$options = unserialize('a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}');

if (isset($options['min_text_length'])) unset($options['min_text_length']);

$installer->addAttribute('customer', 'lastname', array(
    'validate_rules' => serialize($options),
    'required'       => false
));

$installer->addAttribute('customer_address', 'lastname', array(
    'validate_rules' => serialize($options),
    'required'       => false
));

$installer->endSetup();

After that you should hide this field using html+css or js

UPDATE:

Edit file /app/design/frontend/default/YOURTHEME/template/customer/widget/name.phtml to change your registration form. In my case I commented out html block there:

<?php /*if ($this->showMiddlename()): ?>
        <?php $isMiddlenameRequired = $this->isMiddlenameRequired(); ?>
        <div class="field name-middlename">
            <label for="<?php echo $this->getFieldId('middlename')?>"<?php echo $isMiddlenameRequired ? ' class="required"' : '' ?>><?php echo $isMiddlenameRequired ? '<em>*</em>' : '' ?><?php echo $this->getStoreLabel('middlename') ?></label>
            <div class="input-box">
                <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->escapeHtml($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> />
            </div>
        </div>
    <?php endif; */?>

    <!--<div class="field name-lastname">
        <label for="<?php echo $this->getFieldId('lastname')?>" class="required"><em>*</em><?php echo $this->getStoreLabel('lastname') ?></label>
        <div class="input-box">
            <input type="text" id="<?php echo $this->getFieldId('lastname')?>" name="<?php echo $this->getFieldName('lastname')?>" value="<?php echo $this->escapeHtml($this->getObject()->getLastname()) ?>" title="<?php echo $this->getStoreLabel('lastname') ?>" maxlength="255" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('lastname') ?>" <?php echo $this->getFieldParams() ?> />
        </div>
    </div>-->

Also you could add some class to <div class="field name-middlename"> and <div class="field name-lastname">. This class should has css property "display:none;".

Upvotes: 3

Related Questions