PDA

View Full Version : Use Email address as User Name



Omar Barkawi
February 15, 2013, 10:51 AM
Hello,

I want the users to use there email address as the user name. This means that they don't need to enter the email address in the username field. Instead the system should use the email address they entered as the username.

Please advise.

Thanks,

Robert Kranack
May 27, 2015, 12:05 AM
Is this possible? I would like to do the same.

Thanks


Hello,

I want the users to use there email address as the user name. This means that they don't need to enter the email address in the username field. Instead the system should use the email address they entered as the username.

Please advise.

Thanks,

Curtis
May 27, 2015, 03:14 AM
Do you want use email address in the login form?

Viktor
May 27, 2015, 04:10 AM
Hello all,

You can try to use following code:

open file: ftp://includes>>classes>>rlAccount.class.php find method: login and code:



$this -> rlValid -> sql( $username );
$errors = array();

// get account information
$sql = "SELECT `T1`.*, `T2`.`Abilities`, `T2`.`ID` AS `Type_ID`, `T2`.`Own_location`, `T2`.`Status` as `Type_status` ";
$sql .= "FROM `". RL_DBPREFIX ."accounts` AS `T1` ";
$sql .= "LEFT JOIN `". RL_DBPREFIX ."account_types` AS `T2` ON `T1`.`Type` = `T2`.`Key` ";
$sql .= "WHERE `T1`.`Username` = '{$username}' AND `T1`.`Status` <> 'trash'";
$sql .= "AND `T2`.`Status` <> 'trash' ";


and replace to:



$this ->rlValid->sql( $username );
$errors = array();

if ($this->rlValid->isEmail($username)) {
$username_search = "`T1`.`Mail` = '{$username}'";
}
else {
$username_search = "`T1`.`Username` = '{$username}'";
}

// get account information
$sql = "SELECT `T1`.*, `T2`.`Abilities`, `T2`.`ID` AS `Type_ID`, `T2`.`Own_location`, `T2`.`Status` as `Type_status` ";
$sql .= "FROM `". RL_DBPREFIX ."accounts` AS `T1` ";
$sql .= "LEFT JOIN `". RL_DBPREFIX ."account_types` AS `T2` ON `T1`.`Type` = `T2`.`Key` ";
$sql .= "WHERE {$username_search} AND `T1`.`Status` <> 'trash'";
$sql .= "AND `T2`.`Status` <> 'trash' ";


save and then you can use username or email in login form.

Robert Kranack
May 27, 2015, 06:10 PM
Yes, I would like to only have the email address as the login.

Viktor
May 28, 2015, 04:38 AM
Hello Robert,

Please try to use next code:

instead of above code



$this ->rlValid->sql( $username );
$errors = array();

if (!$this->rlValid->isEmail($username)) {
$errors[] = $GLOBALS['lang']['please_write_correct_email'];
return $errors;
} else {
$username_search = "`T1`.`Mail` = '{$username}'";
}

// get account information
$sql = "SELECT `T1`.*, `T2`.`Abilities`, `T2`.`ID` AS `Type_ID`, `T2`.`Own_location`, `T2`.`Status` as `Type_status` ";
$sql .= "FROM `". RL_DBPREFIX ."accounts` AS `T1` ";
$sql .= "LEFT JOIN `". RL_DBPREFIX ."account_types` AS `T2` ON `T1`.`Type` = `T2`.`Key` ";
$sql .= "WHERE {$username_search} AND `T1`.`Status` <> 'trash'";
$sql .= "AND `T2`.`Status` <> 'trash' ";


save and check again.