Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

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

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #31  
Old 07-01-2005, 11:48 AM
 
x-light x-light is offline
 

Member
  
Join Date: Mar 2005
Posts: 29
 

Default

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
__________________
X-Cart 4.xx Gold
Enterprise Linux
Reply With Quote
  #32  
Old 07-17-2005, 08:24 AM
 
jw jw is offline
 

Newbie
  
Join Date: Feb 2005
Location: Netherlands
Posts: 7
 

Default

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
__________________
X-Cart Version 4.0.14
Reply With Quote
  #33  
Old 07-17-2005, 10:02 PM
 
coeus coeus is offline
 

Member
  
Join Date: Mar 2005
Posts: 16
 

Default ...

Nice mod!
__________________
X-cart v4.0.14
Reply With Quote
  #34  
Old 10-04-2005, 04:23 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default

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
__________________
Core version: 5.5.xx
Reply With Quote
  #35  
Old 10-16-2005, 08:39 PM
 
flyingsaucer flyingsaucer is offline
 

Member
  
Join Date: Sep 2005
Posts: 14
 

Default 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
__________________
x-cart 4.0.16 (linux)
location: USA
Reply With Quote
  #36  
Old 12-13-2005, 09:38 PM
 
hyratech hyratech is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 172
 

Default

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
__________________
hyratech
X-CART Gold 4.1.10
Hosted - Unix
Reply With Quote
  #37  
Old 01-11-2006, 11:08 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #38  
Old 02-01-2006, 01:50 PM
 
electronics4less electronics4less is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 38
 

Default

Any successes on X-light's mod on 4.0.9?
__________________
X-cart v4.0.8
Reply With Quote
  #39  
Old 02-05-2006, 02:12 PM
 
electronics4less electronics4less is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 38
 

Default

Works great in 4.0.9, X-light VERY NICE WORK! Thanks!
__________________
X-cart v4.0.8
Reply With Quote
  #40  
Old 02-13-2006, 12:40 PM
 
mukunig mukunig is offline
 

Member
  
Join Date: Aug 2005
Posts: 12
 

Default

Does this work with 4.0.13 pro?

Thanks,
Greg
x-cart pro 4.0.13 heavily modified
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:59 AM.

   

 
X-Cart forums © 2001-2020