Magento – How to remove confirm password field

magento2moduleregistrationvalidation

I want to remove the confirm password validation field in my registration form. How could I do it?

Best Answer

You need to change two places

Comment password confirmation field in Magento/Customer/view/frontend/templates/form/register.phtml

    <div class="field confirmation required">
        <label for="password-confirmation" class="label"><span><?php /* @escapeNotVerified */ echo __('Confirm Password') ?></span></label>
        <div class="control">
            <input type="password" name="password_confirmation" title="<?php /* @escapeNotVerified */ echo __('Confirm Password') ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">
        </div>
    </div>

Change the below line in Magento/Customer/Controller/Account/CreatePost.php

from

$this->checkPasswordConfirmation($password, $confirmation);

to

if(isset($confirmation))
{
    $this->checkPasswordConfirmation($password, $confirmation);
}

Info: Don't change core file directly, you must override the above files from your custom module/theme.

Related Topic