Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Eliana Tamerin on March 16, 2008, 02:17:25 PM

Title: Multiple Accounts, Same Email
Post by: Eliana Tamerin on March 16, 2008, 02:17:25 PM
Question: Can I allow multiple accounts to use the same email address?

Original Topic: http://www.simplemachines.org/community/index.php?topic=224650.0

Like many people who use SMF for roleplaying (RPG) forums, I found myself frustrated at the restrictions on multiple email addresses. I scoured the forums for solutions, but each time there were none. No one could or was willing to provide a solution for this, citing many reasons not to, and offering a few alternatives.

The best alternative was, and still is, the Multiple Personas Mod (http://www.simplemachines.org/community/index.php?topic=20916.0) by jack. This is simple and easy to use, and works great. The only problem is, you still need to register multiple accounts. But at least this way, you don't have to remember five different passwords if you're careful about account security, and you can easily flip to another account to read a PM if necessary.

But I wanted somthing more. Now that I know a bit more about php, I decided to delve into the code myself. Before I go any further, I must interrupt myself for this.

DISCLAIMER: I do not accept any responsibility for the loss of security incurred by this trick.

Proceed at your own risk.

Reasons why you should not use this trick:
-The major issue with this is security. There is a good reason for this function being there.
-Users can log in with email addresses. The email address login defaults to the first account created with that email, so only login by username would be possible.
-Lost password function would be broken with this. It is imperitive, therefore, that if you use this, you make sure you and your members keep track of your passwords.
-If everyone signs up using the same email address and they all have access to this address, then any one of them can change the password for another member's account without that person's knowledge.
-Email notifications sent to same address. This means that if multiple people have registered with the same address, the readers of that email address will see the notifications for all those accounts. Possible security issue. Besides that, PM notification emails would allow everyone to read the PMs of the other members, which would be a loss of privacy.
-This allows spambots nearly unlimited access to your forum. This is not suggested AT ALL for forums that do not need this. I highly suggest you invest time into ensuring that your forum is secure by either admin approval of accounts or multiple anti-spambot measures. I would suggest you use any of the following mods: Akismet Spam Protection, (http://custom.simplemachines.org/mods/index.php?mod=544) No Spam by Guests, (http://custom.simplemachines.org/mods/index.php?mod=369) Anti-Bot Registration Puzzles, (http://custom.simplemachines.org/mods/index.php?mod=1078) Are You Human? (Anti-Bot Check), (http://custom.simplemachines.org/mods/index.php?mod=999) Advanced Visual Verification (captcha), (http://custom.simplemachines.org/mods/index.php?mod=907) or Visual Verification Options (http://custom.simplemachines.org/mods/index.php?mod=734).
-I would highly, highly, highly recommend that you keep any email addresses associated with admin/gmod/mod accounts unique.

And probably the biggest risk of all:
If you have instant registration enabled (Admin CP > Registration > Settings > Method of registration employed for new members), you can seriously wreck your forum by allowing guests to register with YOUR email address and then destroy your forum. Set your registration settings to Member Activation or Member Approval BEFORE you perform this trick.

I would highly suggest using the View Email Permission (http://custom.simplemachines.org/mods/index.php?mod=1088) mod and disabling view permissions for guests, or checking the "Do not reveal contact details of members to guests" (Admin CP > Features and Options > Basic Settings)  option.


Ok, now that you've read my large disclaimer and reasons why you shouldn't use this, I'll continue.

There are three files you need to edit, all in the sources folder. Find subs-members.php, profile.php and register.php.

In both subs-members.php and register.php, find this code:
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE emailAddress = '$_POST[new_email]'
LIMIT 1", __FILE__, __LINE__);
// !!! Separate the sprintf?
if (mysql_num_rows($request) != 0)
fatal_error(sprintf($txt[730], htmlspecialchars($_POST['new_email'])), false);
mysql_free_result($request);


And in profile.php, find this code:
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE ID_MEMBER != $memID
AND emailAddress = '$_POST[emailAddress]'
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
$post_errors[] = 'email_taken';
mysql_free_result($request);


You have three choices. You can:
a) comment out this code.
b) remove this code (BACK UP FIRST!)
c) alter this code

I'll choose c, because the two others are relatively easy to do. And c can impose a limit on the number of accounts that one can register, useful if you have rules against having more than x accounts.

In subs-members.php and register.php, find this line:
if (mysql_num_rows($request) != 0)

and in profile.php, find this line:
if (mysql_num_rows($request) > 0)

and change all three to this:
if (mysql_num_rows($request) > X)

where X is the number you wish to limit it to. I chose to limit it to nine, so mine looks like this:

if (mysql_num_rows($request) > 9)

Save your three files and upload them to your server.

That's it, you're done. You can now register multiple accounts with the same email address. Please remember that I do not take responsibility for any damage or loss of security this change may incur.

In addition

If you or your members are being stumped by the error that results by registering one account and immediately registering a second, here is the fix:

Open up subs-members.php in your sources folder.

Find this line
// Make sure they didn't just register with this session.
if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck']))
fatal_lang_error('register_only_once', false);


And comment it out or remove it. Back up your file first before you do this.

That's it!

Thank you, and I hope you enjoyed this trick.
Title: Re: [TIP/TRICK] Multiple Accounts, Same Email
Post by: H on April 08, 2008, 08:18:30 PM
Topic moved :)
Title: Re: [TIP/TRICK] Multiple Accounts, Same Email
Post by: Eliana Tamerin on April 08, 2008, 10:54:14 PM
Thanks a bunch, H!
Title: Re: Multiple Accounts, Same Email
Post by: day-there on May 02, 2008, 06:27:59 AM
Thanks a lot for sharing :)
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on May 02, 2008, 07:39:37 AM
You're welcome. I hope this helped you, if you use it, and you were able to get it working without any problems.
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on November 21, 2009, 09:56:46 AM
I should update this to inform anyone using this tip/trick that for SMF 2.0 RC2, there is a mod that works much better, called Subaccounts: http://custom.simplemachines.org/mods/index.php?mod=2264
Title: Re: Multiple Accounts, Same Email
Post by: Yahmez on April 18, 2010, 08:41:56 PM
You can also use phpmyadmin to change the email of multiple accounts to the same address.
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on April 18, 2010, 08:51:24 PM
You can, but then any time you attempt to change the Account Settings of an account with a duplicate email, you'll get an error message. This goes for the account owner or the admin.
Title: Re: Multiple Accounts, Same Email
Post by: Yahmez on April 18, 2010, 10:13:28 PM
Hmm... I just tested that with RC3 and it updated the profile without a SMF scolding and I checked the error log and nothing there...
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on April 18, 2010, 10:32:36 PM
Hmm. Well, this is a simpler (or the mod I mentioned) method for those who don't know what they're doing with phpMyadmin.
Title: Re: Multiple Accounts, Same Email
Post by: Yahmez on April 18, 2010, 10:58:19 PM
Well I don't know what I'm doing in phpmyadmin but I managed :P

Not to detract from your tip though, thank you for the clear understanding of how SMF handles this situation. Oh and while I'm at it, thanks for your work w/ simple portal. Really, it's great!
Title: Re: Multiple Accounts, Same Email
Post by: netjockey on May 08, 2010, 12:38:09 PM
well , is there any other way round

like if admin is creating a user from backend (i mean admin cp panel) then it should ignore the email(whether they are unique or duplicate it should ignore the email field and create the account)

and if any user is creating an account from normal registration page it should work as normal(means it should not allow duplicates email)

i have tested the mybb software , it work like these way only, and when you use the forgot password feature of mybb it sends multiple mails to the same address

like user1 and user2 have same address as email1 then two(1 for user1 and 1 for user2) emails will be send to email1
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on May 09, 2010, 01:47:56 AM
There is another way around:

Quote from: Eliana Tamerin on November 21, 2009, 09:56:46 AM
I should update this to inform anyone using this tip/trick that for SMF 2.0 RC2, there is a mod that works much better, called Subaccounts: http://custom.simplemachines.org/mods/index.php?mod=2264

Otherwise, nope, not unless you manually edit the database (which most users don't know how to do, so I wouldn't advocate that). SMF checks for duplicate emails whenever you register or update an email, regardless of who's doing it. It can be a guest, a member or and admin, but SMF checks it all the same.

As for MyBB, I doubt they allow logins via email in that case. SMF does, which is the primary reason for the duplicate email checking. This tip/trick breaks that functionality partially, but such is the price that you pay for getting a little bit of an unorthodox feature.
Title: Re: Multiple Accounts, Same Email
Post by: netjockey on May 09, 2010, 04:10:42 AM
You are Correct mybb does not allow login through email,but that mod you are saying is for smf 2.0 i  am  using smf 1.1.11 latest version
Title: Re: Multiple Accounts, Same Email
Post by: netjockey on May 09, 2010, 04:36:14 AM
Hello, i would like to ask whether it is possible for admins to create account without email id (i mean leaving the email id field blank) from the admin cp

and the normal user registration form (from front) should work as normal

Title: Re: Multiple Accounts, Same Email
Post by: netjockey on May 09, 2010, 05:21:54 AM
hello buddy , i have tried something unusual and it is working like charm , i would like to confirm these from you guys

what i did that change these

$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE emailAddress = '$_POST[new_email]'
LIMIT 1", __FILE__, __LINE__);
// !!! Separate the sprintf?
if (mysql_num_rows($request) != 0)
fatal_error(sprintf($txt[730], htmlspecialchars($_POST['new_email'])), false);
mysql_free_result($request);


to these only in Subs-members.php only

if (allowedTo('moderate_forum') && !$user_info['is_guest'])
{
if (mysql_num_rows($request) > 9)
fatal_error(sprintf($txt[730], htmlspecialchars($regOptions['email'])), false);
mysql_free_result($request);
}
else
{
if (mysql_num_rows($request) != 0)
fatal_error(sprintf($txt[730], htmlspecialchars($regOptions['email'])), false);
mysql_free_result($request);
}


The Result ,

You as a Admin can Create Multiple User account from Admin cp  with same email Address

normal member have to follow the same rule ,ie that they cannot multiple account with same email address

please give feedback about these changes i made, is there any harmful effect?
i have tested it there seem to no problem
Title: Re: Multiple Accounts, Same Email
Post by: netjockey on May 13, 2010, 02:51:53 PM
Will Somebody Care to Reply?  ::)
Title: Re: Multiple Accounts, Same Email
Post by: Alistair Thomson on June 07, 2010, 12:04:41 PM
netjockey, your fix was good for me. I have a forum based on 1.1.2 and maybe that was the problem, but I could not find the code in subs-members.php that either you or the OP had listed.

But I found

if (mysql_num_rows($request) != 0)

occurring just once in subs-members.php and applied your code as appropriate, and it works just fine. In the forum I set up, only Admin is allowed to register members, so since your code works for that scenario I guess profiles.php and register.php can be left untouched. :D
Title: Re: Multiple Accounts, Same Email
Post by: John Willson on June 08, 2010, 04:00:37 AM
Hello every one,Thanks for the shearing.



Title: Re: Multiple Accounts, Same Email
Post by: netjockey on June 13, 2010, 04:11:53 AM
thanks for replying i just wanted confirmation of this
Title: Re: Multiple Accounts, Same Email
Post by: Super_Benno on May 30, 2011, 10:16:50 AM
is it working? no one has confirmed that it works
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on May 30, 2011, 01:43:15 PM
I have successfully used it on a 1.1.x forum, and it works fine there. I haven't tried on 2.0 yet. So, yes, it's confirmed working.
Title: Re: Multiple Accounts, Same Email
Post by: Super_Benno on June 01, 2011, 08:28:29 AM
thank you :))
Title: Re: Multiple Accounts, Same Email
Post by: gadgetsol on October 15, 2011, 06:26:43 PM
How can do it on SMF 2.0.1 ?
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on October 15, 2011, 06:55:32 PM
Honestly, in SMF 2, I'd use SlammedDime's Subaccounts mod. Much cleaner.
Title: Re: Multiple Accounts, Same Email
Post by: gadgetsol on October 16, 2011, 11:36:47 AM
this mod is not parse with SMF 2.0.1 :-(
Title: Re: Multiple Accounts, Same Email
Post by: oruyagercekolsa on October 17, 2011, 05:46:26 PM
Thank you very much hands of health
Title: Re: Multiple Accounts, Same Email
Post by: Jasper79 on November 15, 2011, 02:37:54 AM
well said. That was the point I came here to search on this forum. Thanks a lot being so helpful to me.


Title: Re: Multiple Accounts, Same Email
Post by: Dromo on April 11, 2015, 07:35:45 AM
I've read this thread with a great deal of interest. I have a system where the forum is the backend of a custom application.  The problem I have is that many of the users of the system are couples who share an email address.  I have a workaround for this in that the second member is assigned an email address in my own domain which is then redirected to the original one. However, this is labour-intensive and not 100% reliable. That's why it would be of great benefit to me to be able to have duplicate email addresses inside my forum.

All system administration is done within the application and not on the forum. In addition, the only way into the forum is through the application; the standard way into it is blocked. What this means is that, within the forum, email addresses are only used for sending messages between users. They cannot be used for login and password management  (including the sending of reminders) is within the front end application.

The conclusion of this thread is that, provided you are careful, you can use duplicate email addresses inside a forum. Is this conclusion still valid for version 2.0.7?

Title: Re: Multiple Accounts, Same Email
Post by: Kindred on April 11, 2015, 10:43:50 AM
Quote from: Eliana Tamerin on October 15, 2011, 06:55:32 PM
Honestly, in SMF 2, I'd use SlammedDime's Subaccounts mod. Much cleaner.

In general, it is a bad idea - because the SMF system allows a user to use the email address as an alternative login. So, by doing this - you are either REMOVING a feature or (if it is not removed) setting your site up for issues.

As for couples...   every person in my family has their own email account...   I fail to see why anyone would SHARE email accounts in this day and age - with all of the free account services out therem even aside from most service providers allowing you to have multiple accounts.
Title: Re: Multiple Accounts, Same Email
Post by: Steve on April 11, 2015, 11:00:30 AM
Quote from: Kindred on April 11, 2015, 10:43:50 AMAs for couples...   every person in my family has their own email account...   I fail to see why anyone would SHARE email accounts in this day and age - with all of the free account services out therem even aside from most service providers allowing you to have multiple accounts.

I agree. Good lord, I'd never share an email account with my wife! I kid, there's nothing in my email she can't see if she wants but like Kindred says, why would couples share one? It's much easier for all kinds of reasons, not just SMF ones. :)
Title: Re: Multiple Accounts, Same Email
Post by: Dromo on April 11, 2015, 12:11:57 PM
Steve and Kindred, thanks for replying.  I agree 150% with you about sharing an email account; I would never share an account with a family member - and neither would my wife.  However, the reality of the situation is that I am stuck with these 'till death us do part' guys and I have to live with them.

As I said, access to the forum is via our own front-end which does not use email addresses as a login and I don't need the forum to send password reminders.  The previous discussion on this topic confirmed that allowing duplicates would work (if not advisable for all the reasons stated).  The last post on this was about five years ago and I was just wondering if anything had changed in the code of version 2.0.7 that would change that position.

I'll take a look at the Subaccounts mod - but right now I'm in a hurry.

 
Title: Re: Multiple Accounts, Same Email
Post by: Kindred on April 11, 2015, 12:32:39 PM
No, I am pretty certain these instructions will NOT work with 2.0.x

Also, you should be running 2.0.9, not 2.0.7
Title: Re: Multiple Accounts, Same Email
Post by: Dromo on April 11, 2015, 01:05:30 PM
Just for info., why not?

Title: Re: Multiple Accounts, Same Email
Post by: Kindred on April 11, 2015, 02:53:47 PM
because, as I read it -- the instructions given are for either 1.1.x or 2.0 prior to RC3...    neither of which will work well (if at all) on 2.0.x
Title: Re: Multiple Accounts, Same Email
Post by: Dromo on April 11, 2015, 03:23:56 PM
Okay, I'm sure you know the code much better than I do. I had a look at the mod but it's far too complicated for what I need. So I guess I'm stuck with my workaround.

Thanks for taking the trouble to respond to my post.
Title: Re: Multiple Accounts, Same Email
Post by: Steve on April 11, 2015, 09:59:46 PM
It's no trouble, it's what we do. Especially the support team. :P

And as Kindred said, you should really upgrade to 2.0.9 ... lots of security fixes ... :)
Title: Re: Multiple Accounts, Same Email
Post by: Eliana Tamerin on April 14, 2015, 06:53:04 AM
Quote from: Dromo on April 11, 2015, 07:35:45 AM
I've read this thread with a great deal of interest. I have a system where the forum is the backend of a custom application.  The problem I have is that many of the users of the system are couples who share an email address.  I have a workaround for this in that the second member is assigned an email address in my own domain which is then redirected to the original one. However, this is labour-intensive and not 100% reliable. That's why it would be of great benefit to me to be able to have duplicate email addresses inside my forum.

All system administration is done within the application and not on the forum. In addition, the only way into the forum is through the application; the standard way into it is blocked. What this means is that, within the forum, email addresses are only used for sending messages between users. They cannot be used for login and password management  (including the sending of reminders) is within the front end application.

The conclusion of this thread is that, provided you are careful, you can use duplicate email addresses inside a forum. Is this conclusion still valid for version 2.0.7?

Kindred answered plenty, but to quote my warning from the first post:
Quote-Email notifications sent to same address. This means that if multiple people have registered with the same address, the readers of that email address will see the notifications for all those accounts. Possible security issue. Besides that, PM notification emails would allow everyone to read the PMs of the other members, which would be a loss of privacy.

In other words, this breaks the privacy of Personal Messages. It would be a serious disservice to your members to allow a pair of accounts to have unlimited access to each others' PMs. If you truly wish to allow for this couple, short of introducing them to the joy of anonymous, throwaway emails, I would suggest they simply use a single account for the pair of them. That would be transparent to both you and your members that this account belongs to both members, and any communication with it is going to be viewed by both.

Hope you figure it out.