Disabling Password Confirm Field

Hello,

I want to disable the password confim field so that users can enter their password one time only to register.

I did remove the following code from /templates/views/profiles/profiles_account.tpl

    
{__("confirm_password")}

I also removed all cm-password class. Still I am not able to get it working. I am still getting passwords do not match notification.

Can you help me please in this?

Thank you!

You should also change validation on backend.

Please check this file app/controllers/frontend/profiles.php

if (empty($_REQUEST['user_data']['password1']) || empty($_REQUEST['user_data']['password2'])) {

if (empty($_REQUEST['user_data']['password1'])) {
fn_set_notification('W', __('warning'), __('error_validator_required', array('[field]' => __('password'))));
}

if (empty($_REQUEST['user_data']['password2'])) {
fn_set_notification('W', __('warning'), __('error_validator_required', array('[field]' => __('confirm_password'))));
}
$is_valid_user_data = false;

} elseif ($_REQUEST['user_data']['password1'] !== $_REQUEST['user_data']['password2']) {
fn_set_notification('W', __('warning'), __('error_validator_password', array('[field2]' => __('password'), '[field]' => __('confirm_password'))));
$is_valid_user_data = false;
}

Some code modification will be required.

You should also change validation on backend.

Please check this file app/controllers/frontend/profiles.php

Some code modification will be required.

Thank you very much. I understand now.

Seems that there is no PHP hooks in this controller, Thus, I prefer to keep it as is.

Thank you very much. I understand now.

Seems that there is no PHP hooks in this controller, Thus, I prefer to keep it as is.

No.

You can try to create profile.pre.php and add following code:

if (mode == ...)

$_REQUEST['user_data']['password2'] = $_REQUEST['user_data']['password1'];

Main idea - you need to populate second password manually from first password.

No.

You can try to create profile.pre.php and add following code:

if (mode == ...)

$_REQUEST['user_data']['password2'] = $_REQUEST['user_data']['password1'];

Main idea - you need to populate second password manually from first password.

Thank you very much for your help. I created the file in my addon with the following content:

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == 'update') {
	if (empty($_REQUEST['user_data']['password2'])) {
		$_REQUEST['user_data']['password2'] = $_REQUEST['user_data']['password1'];
	}
}

This worked for the user profile page and registration page. I had also to use the update_user_pre hook to alter another variant for the checkout page.

So it is working now.

Now this will encourage users to register.

:)

You are welcome :)