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 |
You little beauty I was just about to start looking into this! :D
Nice one boomer. |
Rock on!!
Works for me. This should be standard. Most other places just use your email as the unique username, xcart should too. |
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. |
Thanks BOOMER,
If you were a leg, and I was a dog... well you get the point.. Awesome mod |
Quote:
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 ( You may need to add some error catching in include/register.php but atleast noone can register the same email twice. |
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 *} 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 '')} |
Add this to get it to work...
{/if}
:D |
thanks!
|
Good job! I have to use this ASAP on my sites. thanks!
|
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.
|
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.
|
Hello
Just installed this on 4.11 and it works very nicely, thankyou. |
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 file: register.php v1 Code:
# find original code snippet file: include/check_useraccount.php v1 Code:
# find original code snippet file: include/login.php v1 Code:
# mod1 file: include/register.php v1 Code:
# mod1 file: skin1/customer/main/register.tpl v1 Code:
{* find original code snippet *} file: skin1/main/orders_list.tpl v1 Code:
{* find original code snippet *} file: skin1/main/register_account.tpl v1 Code:
{* mod1 *} file: skin1/main/register_contact_info.tpl v1 Code:
{* find original code snippet *} |
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. |
Hi Mustang,
Quote:
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 |
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 and replace with Code:
# mod.use.email.rather.username ~x-light |
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.
|
rated 99/100
keep up the good work thnx! |
Quote:
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:
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 |
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. |
Hi Speedmaster,
Quote:
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:
Actually, it only creates the record when the following is true as shown in the above answer. Quote:
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] |
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.
|
x-light,
Thanks for the info. I'm going to go work on this now. |
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. :(
|
Has anyone done this mod for 3.4.x ??
|
Has anyone modify it in 4.13? Any problems?
I think register.php in /include is a bit different. |
Hi all,
I am glad to hear some feedbacks about this mod. Quote:
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:
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 ~x-light |
Thanks X-light =D>
|
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 |
Hey,
Quote:
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 Code:
# find original code snippet Code:
{* find original code snippet *} Code:
{* find original code snippet *} Code:
{* find original 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 |
I'm using this with 4.0.14 and it works great! Thanks x-light.
Quote:
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:
Quote:
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 |
...
Nice mod!
|
My simple way of doing this (appears to work so far)
In /main/register_account.tpl change Code:
<TR> to Code:
<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 |
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 |
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
|
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: |
Any successes on X-light's mod on 4.0.9?
|
Works great in 4.0.9, X-light VERY NICE WORK! Thanks!
|
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.