X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Use E-mail address instead of username 3.5.x & 4.0 (https://forum.x-cart.com/showthread.php?t=8809)

B00MER 08-05-2004 08:26 PM

Use E-mail address instead of username 3.5.x & 4.0
 
Use E-mail address instead of username for X-Cart 3.5.x & 4.0.

Let users use either their email address or username to login instead of JUST the username.

Edit include/login.php find:

Code:

$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE login='$username' AND usertype='$usertype' AND status='Y'");

Change to:

Code:

$user_data=func_query_first("select * from $sql_tbl[customers] where (login='$username' or email='$username') and usertype='$usertype' and status='Y'");

:!: Should work without troubles on 3.5.x and 4.0.x

groovico 08-06-2004 04:59 AM

You little beauty I was just about to start looking into this! :D

Nice one boomer.

sstillwell@aerostich.com 08-06-2004 06:31 AM

Rock on!!

Works for me.

This should be standard. Most other places just use your email as the unique username, xcart should too.

mizzlewillz 08-10-2004 08:01 AM

This is a nice little mod that should be implemented into x-cart. One question , it has probably been answered before, but how would you check to see if an e-mail address already exists and stop another person from registering an identical e-mail address. I am figuring it is somewhere in include/register.php, but can't seem to locate the where and what type of code to add.

Thanks for any comments.

-Mike W.

1320AutoSports 08-10-2004 08:10 AM

Thanks BOOMER,

If you were a leg, and I was a dog... well you get the point..

Awesome mod

B00MER 08-10-2004 08:13 AM

Quote:

Originally Posted by mizzlewillz
One question , it has probably been answered before, but how would you check to see if an e-mail address already exists and stop another person from registering an identical e-mail address.


Go into phpMyAdmin and set the email field to "Unique" and MySQL will take care of it for you ;) OR login to X-Cart and use the following MySQL code snippet in the Patch SQL area:

Code:

ALTER TABLE `xcart_orders` ADD UNIQUE (
`email`
);
ALTER TABLE `xcart_customers` ADD UNIQUE (
`email`
);


You may need to add some error catching in include/register.php but atleast noone can register the same email twice.

PhilJ 08-13-2004 05:51 AM

Slight addition which adds a checkbox to copy the e-mail field to the username field.

in skin1/check_email_script.tpl add the following code:

Code:

{* COPY E-MAIL AS USERNAME MOD *}

{literal}
<script language="JavaScript1.2">

var uname = "";

function InitSaveVariables(form) {
uname = form.uname.value;
}

function copyemail(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.uname.value = form.email.value;
}

else {
        form.uname.value = uname;
        }
}

</script>
{/literal}


then in skin1/main/register_account.tpl just below the comment

Code:

{* NOT anonymous account *}

add this code:

Code:

{if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')}
{else}
<TR>
<TD align="right"></TD>
<TD></TD>
<TD nowrap>
<input type="checkbox" name="copy" onclick=javascript:copyemail(this.form);>Use E-Mail Address as Username
</TD>
</TR>
{/if}


richard9977 09-05-2004 08:06 AM

Add this to get it to work...
 
{/if}

:D

nfc5382 09-08-2004 05:05 PM

thanks!

TWS Accessories 03-13-2005 07:43 PM

Good job! I have to use this ASAP on my sites. thanks!

issay 03-14-2005 11:47 PM

In this case, when customers register, can they still specify a username? Can we make the customers type the email address only since having username and email maybe a bit confusing.

B00MER 03-15-2005 07:34 AM

Yes, but you'll need to modify include/register.php to remove any username/password validation checks, along with removing the input fields from the register form.

mrbiggles 03-16-2005 01:38 AM

Hello
Just installed this on 4.11 and it works very nicely, thankyou.

x-light 03-22-2005 04:36 PM

use email rather username
 
Hello all,

As I am new to this forum, but not new to development work, I would like to share a token of my appreciation for all the great custom mods everyone has been sharing by contributing to a rather complete solution for this topic. Btw, thanks Boomer for starting this important topic. I have tested it with 4.0.12 only and so far everything seem to work well according to the features I have outlined below.

For security purpose, I will only post code here in this forum and it's rather long so bear with me. I will be busy the next couple days, but will try my best to answer to questions that you may have regarding to this mod. Enjoy :)

~x-light

-------------------------------------------------------------------------------------
Description: This mod allow all users customers, admins to use their email to register for an account and login instead of username. It modifies the register process to automatically generate an unique Id for the username during the registration process. If the user is anonymous, it resorts back to the default "anonymous+1"username X-Cart uses.

Key feature:
* checks for duplicate email during user registration or user profile updates and return appropriate errors.
* The user can also change their email at any time as long as their email has no duplicates.
* To avoid confusion, customers can only login using their email.
* If the user is an administrator, he/she can login using either their username or email.
* During an anonymous checkout, anonymous users can use same email to register again since register will drop previous anonymous user's record with the same email. This should be ok since the orders table is not affected and anonymous user aren't really suppose to login-in in the first place. However, anonymous user that happen to request a email which has already been used by a registered user will be denied. Please see comment in include/register.php starting with "# delete this record since the user is anonymous requesting the same email" for detailed explanation.

Modified for X-Cart Gold: Version 4.0.12 stock

Tested with: Version 4.0.12 stock
Apache 1.33, OpenSSL 0.9.6b, PHP 4.3.10, SQL 4.0.22

Intended Audience: This mod requires changes to various php, tpl files and some sql table(s) as well as outlined in "General Overview" below. If you are a store owner and have met the requirements for the modified and tested X-Cart versions, you can follow the instructions below and it should work. However, if you intend to make this mod work with previous X-Cart versions or make any changes to this mod, it is recommended that you hire a developer with development and coding knowledge to perform this task.

Disclaimer: This mod may work on other X-Cart versions, but it has not been tested. Therefore, use it at your own risk. We are not responsible for any loss in sales, time spent or damages that is direct or indirectly caused by this modification to your store. By using this modification, you have agreed all the terms to the license agreement and hold all personel indemfiable and harmless including but not limited to owners, shareholders, stakeholders, employees, contractors, or anyone else related to the business.

License: None/Freeware

As usual, always backup your current store or try it on a development store before integrating this with production.

General Overview:

files modified application logic related:
sql table modification
xcart_customers
files modified application logic related:
include/login.php
include/register.php
frontend gui related:
register.php include/check_useraccount.php
skin1/customer/main/register.tpl skin1/main/register_account.tpl
skin1/main/register_contact_info.tpl skin1/main/orders_list.tpl

each code section which has been modified has the comment header:
mod.use.email.rather.username

Instructions:

Prerequisites:
BACKUP, BACKUP, BACKUP!!
make sure no duplicate email exist in xcart_customers table also
make sure email field is active and required for admin and customers.
Also, remember that customers can only login using their emails once this mod is added.

Installation:

1. update sql table using ssh or sql patch from admin menu
If using ssh, issue command:
"mysql -u username -p dbname < update_tables.sql"
If using sql patch just use the command
"ALTER TABLE xcart_customers ADD UNIQUE (email);"

2. modify code
a. match the code section under the "find original code snippet" and "end original code snippet" with your source
b. replace original code section with the code section under the "replace modified code snippet"

3. repeat step 2 for each php and template files until all are done

-------------------------------------------------------------------------------------
file: update_tables.sql v1
Code:

# this script will make the following field(s) unique to avoid duplication

# table(s) affected
# xcart_customers

# field(s) affected
# email

ALTER TABLE xcart_customers ADD UNIQUE (email);

-------------------------------------------------------------------------------------
file: register.php v1
Code:

# find original code snippet
if ($REQUEST_METHOD == "POST" && $action == "cart") {

        if (empty($reg_error))
                func_header_location("cart.php?mode=checkout&paymentid=$paymentid");
}

$smarty->assign("login",$login);
# end original code snippet

# replace modified code snippet
if ($REQUEST_METHOD == "POST" && $action == "cart") {

        if (empty($reg_error))
                func_header_location("cart.php?mode=checkout&paymentid=$paymentid");
}

# mod.use.email.rather.username
$smarty->assign("login", func_query_first_cell("select email from $sql_tbl[customers] where login='$login'"));
# end modified code snippet

-------------------------------------------------------------------------------------
file: include/check_useraccount.php v1
Code:

# find original code snippet
$smarty->assign("login",$login);
$smarty->assign("usertype",$current_area);
# end original code snippet

# replace modified code snippet
# mod.use.email.rather.username
$smarty->assign("login", func_query_first_cell("select email from $sql_tbl[customers] where login='$login'"));
$smarty->assign("usertype",$current_area);
# end modified code snippet

-------------------------------------------------------------------------------------
file: include/login.php v1
Code:

# mod1
# find original code snippet
switch ($redirect) {
        case "admin":
                $redirect_to = DIR_ADMIN;
                break;
        case "provider":
                $redirect_to = DIR_PROVIDER;
                break;
        case "partner":
                $redirect_to = DIR_PARTNER;
                break;
        case "customer":
        default:
                $redirect_to = DIR_CUSTOMER;
}
# end original code snippet

# replace modified code snippet
switch ($redirect) {
        case "admin":
                $redirect_to = DIR_ADMIN;
# mod.use.email.rather.username
        $c_area = 'A';
                break;
        case "provider":
                $redirect_to = DIR_PROVIDER;
                break;
        case "partner":
                $redirect_to = DIR_PARTNER;
                break;
        case "customer":
        default:
                $redirect_to = DIR_CUSTOMER;
}
# end modified code snippet


# mod2
# find original code snippet
if ($REQUEST_METHOD == "POST") {
        $intershipper_recalc = "Y";
        if ($mode == "login") {

                $username = $HTTP_POST_VARS["username"];
                $password = $HTTP_POST_VARS["password"];

        $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE email='$username' AND usertype='$usertype' AND status='Y'");
# end original code snippet

# replace modified code snippet
if ($REQUEST_METHOD == "POST") {
        $intershipper_recalc = "Y";
        if ($mode == "login") {

                $username = $HTTP_POST_VARS["username"];
                $password = $HTTP_POST_VARS["password"];

# mod.use.email.rather.username
# exception if current area is admin, use username or email instead
    if( $c_area == 'A' ) {
        $c_area = '';
                $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE (login='$username' OR email='$username') AND usertype='$usertype' AND status='Y'");
    }
    else
        $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE email='$username' AND usertype='$usertype' AND status='Y'");
# end modified code snippet

-------------------------------------------------------------------------------------
file: include/register.php v1
Code:

# mod1
# find original code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");
    }
# end original code snippet

# replace modified code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");

# mod.use.email.rather.username
# generate unique id number as username since email is used as unique key in customers and order table
# only for non-anonymous users
        if( !$anonymous_user ){
            for( $i=0; $i<3; $i++ ){
                $u_tmp = uniqid(rand());
                if( $login != $u_tmp )
                    break;
            }
            $uname = $u_tmp;
        }
    }
# end modified code snippet


# mod2
# find original code snippet
                foreach($default_fields as $k => $v) {
                        if($v['required'] == 'Y' && empty($$k) && $v['avail'] == 'Y') {
                                if(($k == "b_county" || $k == 's_county')) {
                                        if($config["General"]["use_counties"] == "Y") {
                                                $fillerror = true;
                                                break;
                                        }
                                } elseif($k != 'b_state' && $k != 's_state') {
                                        $fillerror = true;
                                        break;
                                } elseif($k == 's_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$s_country'") == 'Y') {
                                        $fillerror = true;
                                        break;
                                } elseif($k == 'b_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$b_country'") == 'Y') {
                                        $fillerror = true;
                                        break;
                                }
                        }
                }
# end original code snippet

# replace modified code snippet
                foreach($default_fields as $k => $v) {
                        if($v['required'] == 'Y' && empty($$k) && $v['avail'] == 'Y') {
                                if(($k == "b_county" || $k == 's_county')) {
                                        if($config["General"]["use_counties"] == "Y") {
                                                $fillerror = true;
                                                break;
                                        }
                                } elseif($k != 'b_state' && $k != 's_state') {
                                        $fillerror = true;
                                        break;
                                } elseif($k == 's_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$s_country'") == 'Y') {
                                        $fillerror = true;
                                        break;
                                } elseif($k == 'b_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$b_country'") == 'Y') {
                                        $fillerror = true;
                                        break;
                                }
                        }
                }

# mod.use.email.rather.username
# check if email already exist in customers table
        if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) {
                # duplicate email not allowed
                $eerror = true;
        }

# exception checks to this rule
        if( $mode != "update") {
            # check if this is anonymous registration during checkout
            if( $eerror && func_query_first_cell("select status from $sql_tbl[customers] where email='$email' and usertype='C'") == 'A' ) {
                # delete this record since the user is anonymous requesting the same email
                # we can't assume that the email belongs to the user, but at least this way
                # the original user can use his/her same email to register again anonymously during another checkout
                # if an anonymous user already placed an order with this email, it will not effect the orders table
                # since it is a seperate record
                # note, if the user is already registered, we will never allow to automatically delete the registered user's record
                db_query("DELETE FROM $sql_tbl[customers] WHERE login LIKE 'anonymous%' AND email='$email' and usertype='C' AND status='A'");
                # this is not an error since we have deleted this record
                $eerror = false;
            }
        }
        else {
            if( $email == func_query_first_cell("select email from $sql_tbl[customers] where login='$login' and email='$email'")) {
                # email match, user did not change email
                $eupdate = false;
                # this is not an error since the existing email belong to this user
                $eerror = false;
            }
            else {
                # email does not match, see if new requested email is taken
                if( !$eerror )
                    $eupdate = true;
            }
        }
# end modified code snippet

# mod3
# find original code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end original code snippet

# replace modified code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";

# mod.use.email.rather.username
# update email only if eupdate is true
            if( !$eupdate )
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
            else
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end modified code snippet

-------------------------------------------------------------------------------------
file: skin1/customer/main/register.tpl v1
Code:

{* find original code snippet *}
{include file="main/register_account.tpl" userinfo=$userinfo}
{* end original code snippet *}

{* replace modified code snippet *}
{* mod.use.email.rather.username, include register_account.tpl if not using anonymous checkout *}
{if not ($anonymous ne "" and $config.General.disable_anonymous_checkout ne "Y")}
{include file="main/register_account.tpl" userinfo=$userinfo}
{/if}
{* end modified code snippet *}

-------------------------------------------------------------------------------------
file: skin1/main/orders_list.tpl v1
Code:

{* find original code snippet *}
<TD>{$orders[oid].firstname} {$orders[oid].lastname} ({$orders[oid].login})</TD>
{* end original code snippet *}

{* replace modified code snippet *}
{* mod.use.emai.rather.username *}
<TD>{$orders[oid].firstname} {$orders[oid].lastname} ({$orders[oid].email})</TD>
{* end modified code snippet *}

-------------------------------------------------------------------------------------
file: skin1/main/register_account.tpl v1
Code:

{* mod1 *}
{* find original code snippet *}
{* Anonymous account *}

<TR>
<TD colspan="3">{$lng.txt_anonymous_account_msg}</TD>
</TR>

<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}">
</TD>
</TR>
{* end original code snippet *}

{* replace modified code snippet *}
{* Anonymous account *}

<TR>
<TD colspan="3">{$lng.txt_anonymous_account_msg}</TD>
</TR>

{* mod.use.email.rather.username, show email for username instead *}
{if $default_fields.email.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_email}</TD>
<TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}">
{if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{* mod.use.email.rather.username, disable this since no need to show username *}
{if 0}
<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}">
</TD>
</TR>
{/if}
{* end modified code snippet *}



{* mod2 *}
{* find original code snippet *}
{* NOT anonymous account *}

<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD class="Star">*</TD>
<TD nowrap>
{if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')}
{$userinfo.login|default:$userinfo.uname}
<INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}">
{else}
<INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo.login}{/if}">
{if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<FONT class="Star">&lt;&lt;</FONT>{/if}
{/if}
</TD>
</TR>

<TR>
<TD align="right">{$lng.lbl_password}</TD>
<TD><FONT class="Star">*</FONT></TD>
<TD nowrap><INPUT type="password" id="passwd1" name="passwd1" size="32" maxlength="32" value="{$userinfo.passwd1}">
{if $reg_error ne "" and $userinfo.passwd1 eq ""}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{* end original code snippet *}

{* replace modified code snippet *}
{* NOT anonymous account *}

{* mod.use.email.rather.username, show email for username instead *}
{if $default_fields.email.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_email}</TD>
<TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}">
{if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{* mod.use.email.rather.username, disable this since no need to show username *}
{if 0}
<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD class="Star">*</TD>
<TD nowrap>
{if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')}
{$userinfo.login|default:$userinfo.uname}
<INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}">
{else}
<INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo.login}{/if}">
{if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<FONT class="Star">&lt;&lt;</FONT>{/if}
{/if}
</TD>
</TR>
{/if}

{* mod.use.email.rather.username, output hidden username for include/register.php verification *}
<INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}">

<TR>
<TD align="right">{$lng.lbl_password}</TD>
<TD><FONT class="Star">*</FONT></TD>
<TD nowrap><INPUT type="password" id="passwd1" name="passwd1" size="32" maxlength="32" value="{$userinfo.passwd1}">
{if $reg_error ne "" and $userinfo.passwd1 eq ""}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{* end modified code snippet *}

-------------------------------------------------------------------------------------
file: skin1/main/register_contact_info.tpl v1
Code:

{* find original code snippet *}
{if $default_fields.phone.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_phone}</TD>
<TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}">
{if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.email.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_email}</TD>
<TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}">
{if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.fax.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_fax}</TD>
<TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}">
{if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{if $default_fields.url.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_web_site}</TD>
<TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}">
{if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{include file="main/register_additional_info.tpl" section="C"}
{/if}
{* end original code snippet *}




{* replace modified code snippet *}
{* mod.use.email.rather.username, added a section suitable for anonymous accounts *}
{if $anonymous ne "" and $config.General.disable_anonymous_checkout ne "Y"}

{* Anonymous account *}

{if $default_fields.phone.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_phone}</TD>
<TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}">
{if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>

{if $default_fields.email.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_email}</TD>
<TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}">
{if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.fax.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_fax}</TD>
<TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}">
{if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{if $default_fields.url.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_web_site}</TD>
<TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}">
{if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{include file="main/register_additional_info.tpl" section="C"}
{/if}

{* /Anonymous account *}

{else}

{* NOT anonymous account *}

{if $default_fields.phone.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_phone}</TD>
<TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}">
{if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{* mod.use.email.rather.username, disable this and move to register_account.tpl *}
{if 0}
{if $default_fields.email.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_email}</TD>
<TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}">
{if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{/if}

{if $default_fields.fax.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_fax}</TD>
<TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}">
{if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{if $default_fields.url.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_web_site}</TD>
<TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}">
{if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{include file="main/register_additional_info.tpl" section="C"}
{/if}

{/if}
{* end modified code snippet *}


mustang 03-25-2005 07:27 AM

I'd love to only allow users to use the email address in place of their username. It makes things much simpler for them.

My only problem is with the phone orders that are received. I'd like to allow either anonymous checkout or username checkout for these orders, since many of these people do not have email addresses. Maybe even use their telephone number as the username for these orders!

Any ideas on how this should be done??

Thanks.

x-light 03-25-2005 05:38 PM

Hi Mustang,

Quote:

My only problem is with the phone orders that are received. I'd like to allow either anonymous checkout or username checkout for these orders, since many of these people do not have email addresses. Maybe even use their telephone number as the username for these orders!

So what you are saying is that people without email addresses uses their phone as primary contact? If that is the case, you don't need this mod. I wouldn't recommend using their telephone number as the username as people's number do change. To X-Cart, the username is the primary and unique key so you don't want to change that very often if possible.

However, if you want to still use email without the username with customers , you can make a small adjustment to the login procedure to allow customers to login from email (for your email customers) or phone instead (for your phone customers). In registration, you may want to add a check to see if the customer enters a phone, then email is not necessary as a required field or vs. versa. I would still keep the username hidden and use the system to generate a unique id so not to confuse the customer. Let me know if this helps.

~x-light

x-light 03-25-2005 10:19 PM

minor update (forcing all emails to lowercase)
 
I forgot a minor detail where the code will allow duplicate email address thus cause an duplicate entry error in mysql since the email tests do not check for case sensitivity. The problem can be easily fixed by forcing all email address entries either at initial registration or profile updates to lowercase. Here is what you need to change.

file: include/register.php v1

find this section of code

Code:

# mod.use.email.rather.username
# check if email already exist in customers table     
        if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) {
                # duplicate email not allowed
                $eerror = true;
        }


and replace with

Code:

# mod.use.email.rather.username
# check if email already exist in customers table
        $email = strtolower($email);
        if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) {
                # duplicate email not allowed
                $eerror = true;
        }


~x-light

sportruck 03-31-2005 02:13 PM

Awesome, I got this mod working. Thanks for posting. There are a few places you need to modify different files and messages to make it consistent. Such as the emails (so users don't see their random username), password recovery, and login sections.

2019 04-01-2005 01:52 AM

rated 99/100
keep up the good work
thnx!

x-light 04-01-2005 02:07 PM

Quote:

Awesome, I got this mod working. Thanks for posting. There are a few places you need to modify different files and messages to make it consistent. Such as the emails (so users don't see their random username), password recovery, and login sections.

Your welcome. Humm, I thought I already did that for login. However, if you have already made changes to the emails and password recovery section, please post the changes. I am quite busy working on other mods and may not be able to get back to this one right away. Thanks for pointing this out, see this is what's so great about this forum. Very informative feedbacks.


Quote:

rated 99/100
keep up the good work
thnx!

Hi, thanks for the feedback. I appreciate it. I will be posting a few more useful mods in the near future. Currently I am working on a mod that validates fields for registration on the server side. I looked for this everywhere in the forum and couldn't find it. So, I will write my own. I will post this mod soon as it is very important to validate your customer information before you send it to the sql db.

~x-light

Speedmaster 04-01-2005 06:12 PM

x-light,

It looks like this mod still allows anonymous checkout? How can a returning customer checkout anonymously if the email field is unique?

Also, let me know if I am understanding this correctly. When a customer enters his/her info during checkout, your mod creates the customer if the email is unique, but deletes it if it finds out the customer is checking out anonymously?

One more thing, our store has been live for a while so we have some customers. The last time I checked, we have up to 800 customers who have anonymously checked out more than once (in other words, we have a lot of duplicate emails). How can we remove or handle those?

Thanks.

x-light 04-03-2005 12:38 PM

Hi Speedmaster,

Quote:

It looks like this mod still allows anonymous checkout? How can a returning customer checkout anonymously if the email field is unique?

That's a good question. This relates to your second question. When a customer checks out anonymously, the mod will check to see if a his/her email exist in the customers table. If it does exist and it belongs to an anonymous user, it will first delete that specific record and create a new one with that email. However, if the email exist and it belongs to an registered user, the mod will set the eerror and an duplicate email error will be returned to the user. This should be safe since anonymous users only log in to place an order once and if they do place an order, a seperate order record is placed in the orders table.

Quote:

Also, let me know if I am understanding this correctly. When a customer enters his/her info during checkout, your mod creates the customer if the email is unique, but deletes it if it finds out the customer is checking out anonymously?

Actually, it only creates the record when the following is true as shown in the above answer.

Quote:

One more thing, our store has been live for a while so we have some customers. The last time I checked, we have up to 800 customers who have anonymously checked out more than once (in other words, we have a lot of duplicate emails). How can we remove or handle those?

Well I don't know exaclty what you want to do with this. However, if I understand you correctly, it sounds like you want to remove records that has duplicate emails. I think what you may need is a custom script which access the customers table outside x-cart and do some logic checking. However, since you are running a live store, I would definitely backup your entire database just in case if the script deletes the wrong records. You can whip up a script which retreives all anonymous customers from the customer table do perform the following logic:

1. store each records with with same email in an list of arrays
2. compare to see if the first_login time is newer than the previous one if exist if, so keep this record, else delete this record (this ensures that the emails should be most recent after all duplicate is removed)

That should be it, after you run a script which perform these logic, your customer table should have no duplicate emails along with the latest first_login time for each of them. Hope this helps.

~x-light
[/code]

Grumpy 04-03-2005 06:34 PM

Email Address
 
OK, so what happens when the user changes their email address? I think a user name is a far simpler approach. Also easier to log in with.

Speedmaster 04-04-2005 11:49 AM

x-light,

Thanks for the info. I'm going to go work on this now.

phil_ 04-22-2005 06:07 AM

Did anyone get the x-light code implemented for the 3.5x branch? I would really like this mod, but as soon as I changed the code to use 'func_query_first cell' it seemes to fall down. :(

Lingerieblowout 04-22-2005 11:05 AM

Has anyone done this mod for 3.4.x ??

usiripakdi 04-22-2005 09:12 PM

Has anyone modify it in 4.13? Any problems?
I think register.php in /include is a bit different.

x-light 04-23-2005 12:38 AM

Hi all,

I am glad to hear some feedbacks about this mod.

Quote:

Did anyone get the x-light code implemented for the 3.5x branch? I would really like this mod, but as soon as I changed the code to use 'func_query_first cell' it seemes to fall down.

Code:

Has anyone done this mod for 3.4.x ??

hey guys, unfortunately I don't have v3.4.x or 3.5x release so I would not know how much work is required to make it compatible. I only have v4.0.12 and v4.0.13 release. Also, I have been working on other mods to customize my store so I won't have too much time in looking at this. Hopefully, someone out there with your versions finds this mod useful and make the proper modifications. Good luck.

Quote:

Has anyone modify it in 4.13? Any problems?
I think register.php in /include is a bit different.

hello usiripakdi, actually, I switched from v4.0.12 to v4.0.13 so I have the updated code. There isn't much difference between these 2 versions as far as the mod is concerned. Here is the updated code.

------------------------------------
include/register.php v3

Code:

# mod1
# find original code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");
    }
# end original code snippet

# replace modified code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");

# mod.use.email.rather.username
# generate unique id number as username since email is used as unique key in customers and order table
# only for non-anonymous users
        if( !$anonymous_user ){
            for( $i=0; $i<3; $i++ ){
                $u_tmp = uniqid(rand());
                if( $login != $u_tmp )
                    break;
            }
            $uname = $u_tmp;
        }
    }
# end modified code snippet


# mod2
# find original code snippet
        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));
# end original code snippet

# replace modified code snippet
# mod.use.email.rather.username
    if(!$fillerror) {
        # check if email already exist in customers table
        $email = strtolower($email);
        if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) {
                # duplicate email not allowed
                $eerror = true;
        }

        # exception checks to this rule
        if( $mode != "update") {
            # check if this is anonymous registration during checkout
            if( $eerror && func_query_first_cell("select status from $sql_tbl[customers] where email='$email' and usertype='C'") == 'A' ) {
                # delete this record since the user is anonymous requesting the same email
                # we can't assume that the email belongs to the user, but at least this way
                # the original user can use his/her same email to register again anonymously during another checkout
                # if an anonymous user already placed an order with this email, it will not effect the orders table
                # since it is a seperate record
                # note, if the user is already registered, we will never allow to automatically delete the registered user's record
                db_query("DELETE FROM $sql_tbl[customers] WHERE login LIKE 'anonymous%' AND email='$email' and usertype='C' AND status='A'");
                # this is not an error since we have deleted this record
                $eerror = false;
            }
        }
        else {
            if( $email == func_query_first_cell("select email from $sql_tbl[customers] where login='$login' and email='$email'")) {
                # email match, user did not change email
                $eupdate = false;
                # this is not an error since the existing email belong to this user
                $eerror = false;
            }
            else {
                # email does not match, see if new requested email is taken
                if( !$eerror )
                    $eupdate = true;
            }
        }
        } // mod.use.email.rather.username

        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));
# end modified code snippet

# mod3
# find original code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end original code snippet

# replace modified code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";

# mod.use.email.rather.username
# update email only if eupdate is true
            if( !$eupdate )
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
            else
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end modified code snippet


~x-light

usiripakdi 04-23-2005 01:54 AM

Thanks X-light =D>

2019 06-30-2005 11:40 PM

passing to 4.0.14 any code changes? :(
updated and all my custom work fly away closed to shop to fix them out :(

for example register.php in root is different on 4.0.14 :(

x-light hear my cry

x-light 07-01-2005 11:48 AM

Hey,


Quote:

passing to 4.0.14 any code changes? icon_sad.gif
updated and all my custom work fly away closed to shop to fix them out icon_sad.gif

for example register.php in root is different on 4.0.14 icon_sad.gif

Sorry to hear that you are having trouble. I hoped you made a backup before applying this mod. As I indicated in your pm, this mod is only tested for 4.0.13 and NOT for 4.0.14. I guess there are some differences in the register code which may make this mod incompatible. Anyway, I will send you another pm regarding this.

Now, as promised, I will post the updated code tested with 4.0.13 below. There was a bug in the dupliate email check when doing an update in the include/register. It is fixed in the updated code. I also will post some changes to templates such as recover password, profile modified etc... to show the email address instead of the auto generated username id. Hopefully, this update should be the last one as I have tested it extensively with 4.0.13. If you find any problems, please let me know. Thanks.

--- /include/register.php v3.mod2
Code:

# mod2
# find original code snippet
        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));
# end original code snippet

# replace modified code snippet
# mod.use.email.rather.username
    if(!$fillerror) {

        # check if email already exist in customers table
        $email = strtolower($email);
        $email_on_record = func_query_first_cell("select email from $sql_tbl[customers] where email='$email'");
        if( $email == $email_on_record) {
                # duplicate email not allowed
                $eerror = true;
        }

        # exception checks to this rule
        if( $mode != "update") {
            # check if this is anonymous registration during checkout
            if( $eerror && func_query_first_cell("select status from $sql_tbl[customers] where email='$email' and usertype='C'") == 'A' ) {
                # delete this record since the user is anonymous requesting the same email
                # we can't assume that the email belongs to the user, but at least this way
                # the original user can use his/her same email to register again anonymously during another checkout
                # if an anonymous user already placed an order with this email, it will not effect the order information
                # since it is a seperate record in the orders table
                # note, if the user is already registered, we will never allow to automatically delete the registered user's record
                db_query("DELETE FROM $sql_tbl[customers] WHERE login LIKE '$like_anonymous_username_prefix' AND email='$email' AND usertype='C' AND status='A'");
                # this is not an error since we have deleted this record
                $eerror = false;
            }
        }
        else {
        // update mode
            if( $email == func_query_first_cell("select email from $sql_tbl[customers] where login='$login'")) {
                # email match, user did not change email
                $eupdate = false;
                # this is not an error since the existing email belong to this user
                $eerror = false;
            }
            else {
                # email does not match, see if new requested email is taken (duplicate email check above)
                if( !$eerror )
                    $eupdate = true;
            }
        }
        } // mod.use.email.rather.username

        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));

# end modified code snippet

--- /include/help.php
Code:

# find original code snippet
#
# Recover password
#
if ($REQUEST_METHOD=="POST" and $action=="recover_password") {
$accounts = func_query("select login, password, usertype from $sql_tbl[customers] where email='$email' and status='Y'");

# end original code snippet

# replace modified code snippet
#
# Recover password
#
if ($REQUEST_METHOD=="POST" and $action=="recover_password") {
# mod.use.email.rather.username, replace login with email into accounts
$accounts = func_query("select email, password, usertype from $sql_tbl[customers] where email='$email' and status='Y'");
# end modified code snippet

--- /skin1/help/contactus.tpl
Code:

{* find original code snippet *}
<TR valign="middle">
<TD class="FormButton">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{$userinfo.login}">
</TD>
</TR>
{* end original code snippet *}

{* replace modified code snippet *}
{* mod.use.email.rather.username, username not needed anymore *}
{if 0}
<TR valign="middle">
<TD class="FormButton">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{$userinfo.login}">
</TD>
</TR>
{/if}
{* end modified code snippet *}

* Note: You can delete the code inside the {if 0}{/if} block since smarty will never execute it.  It is there for reference only.

--- /skin1/mail/html
Code:

{* find original code snippet *}
<TD><TT>{$accounts[acc_num].login}</TT></TD>
{* end original code snippet *}

{* replace modified code snippet *}
{* mod.use.email.rather.username, show email instead *}
<TD><TT>{$accounts[acc_num].email}</TT></TD>
{* end modified code snippet *}

--- /skin1/mail/html/profile_data.tpl
Code:

{* find original code snippet *}
<TD width="80%"><TT>{$userinfo.login}</TT></TD>
{* end original code snippet *}

{* replace modified code snippet *}
{* mod.use.email.rather.username, show email instead *}
<TD width="80%"><TT>{$userinfo.email}</TT></TD>
{* end modified code snippet *}


------- The following changes below are completely optional. It changes the s the username to email for order export on regular csv or quickbooks. Just follow the instructions in the comment to make the change to the file.
--- /skin1/main/orders_export.tpl
{* mod.use.email.rather.username, replaced all $orders[oid].login with $orders[oid].email *}
--- /skin1/modules/QuickBooks/orders_export_qb.tpl
{* mod.use.email.rather.username, replaced all $orders[oid].login with $orders[oid].email *}

~x-light

jw 07-17-2005 08:24 AM

I'm using this with 4.0.14 and it works great! Thanks x-light.

Quote:

passing to 4.0.14 any code changes?
updated and all my custom work fly away closed to shop to fix them out

for example register.php in root is different on 4.0.14

2019, this works with 4.0.14. Just start with the changes at the beginning of this thread and work through them. If you get errors chances are you've missed something.

Quote:

--- /skin1/mail/html
Code:
should of course be --- /skin1/mail/html/password_recover.tpl.

Quote:

OK, so what happens when the user changes their email address? I think a user name is a far simpler approach. Also easier to log in with.

The Amazon way is simple. The user can change their e-mail address by logging in and supplying their old address, new address and password. A confirmation is then sent to the new address. I'm working on this and will post is as soon as I'm done.

Jeff

coeus 07-17-2005 10:02 PM

...
 
Nice mod!

xgarb 10-04-2005 04:23 AM

My simple way of doing this (appears to work so far)

In /main/register_account.tpl

change

Code:

<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}">
</TD>
</TR>



to

Code:

<TR>
<TD align="right">{$lng.lbl_username}</TD>
<TD></TD>
<TD nowrap>
<INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}" onchange="javascript: checkEmailAddress(this);">
{if $fillerror ne "" and $userinfo.email eq "" && $default_fields.email.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>


You should also change the string for $lng.lbl_username to something like 'Email Address'. Easiest to do in webmaster mode I find.

This forces the user (using javascript) to put in an email address as their username.

HTH

xgarb

flyingsaucer 10-16-2005 08:39 PM

this is far simpler approach
 
I think this way it makes it easier as well to upgrade since not sql changes or any php changes required.

I was thinking of doing something similar too, like showing the user the email field and password field only and once they enter the email , then copy that info to the username field in a hidden way before saving to database.

And their username and email address will be identical. That way the rest of the x-cart features will still work normally. However I am not very good at making these kind of changes.

Can anyone help me on that.

Hide username field, show email field and copy email entered to hidden username field bfore writing to database.

thanks

hyratech 12-13-2005 09:38 PM

I tried x-light's MOD on 4.0.17 .. I didn't wort.. i got all sort of errors.. can someone varify? is it me? Did i make a mistake somewhere.. or this is not compatible with my version

B00MER 01-11-2006 11:08 AM

Just updating my original post for 4.0.16+:

The $user_data query is different in my original post in include/login.php, look for this code now:
Code:

$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE login='$username' AND usertype='$usertype' AND status='Y'");

Replace with:

Code:

$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE (login='$username' or email='$username') AND usertype='$usertype' AND status='Y'");

Since this is such a minimal php change, patch tools *SHOULD* be able to update this line without much trouble. Keep in mind Upgrade kits also upgrade template .tpl files as well. :wink:

electronics4less 02-01-2006 01:50 PM

Any successes on X-light's mod on 4.0.9?

electronics4less 02-05-2006 02:12 PM

Works great in 4.0.9, X-light VERY NICE WORK! Thanks!

mukunig 02-13-2006 12:40 PM

Does this work with 4.0.13 pro?

Thanks,
Greg
x-cart pro 4.0.13 heavily modified


All times are GMT -8. The time now is 01:05 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.