Posted by chaloum on January 15, 2013 at 10:49am
I'm using user_save to create new users but I need a way to identify if the user already exist (I can do this using user_load_by_mail()) and then determine if it is an update for an existing record or a new user but with the same address which will generate an alert.
Where it's coming unstuck is is the account exists it then updates the user with the new users data but I need a method to check that its a duplicate email but a different user and then to generate an alert.
Any ideas on how to do this
Thanks
Comments
Need more info
There are lots of solutions here, depending on the specifics of your problem. First of all there is a 7.x module (dev version mind you) of shared email which would allow you to use accounts with the same email. I haven't used it and this sounds like it could cause issues elsewhere in Drupal but users are reporting in the issue queue that the current dev version does "work".
http://drupal.org/project/sharedemail
Also, it sounds like you just need to add some conditions in your code:
if (!$user = user_load_by_mail($email)) {// create a new user object and use user_save to create account
} else {
// other action
}
Not sure what exactly you mean by "alert" either.
~Chad
Chad, that won't work as it
Chad, that won't work as it just ends up over writing the existing account
As in my question it about how to trigger an update or a new record or an alert
http://edmedia.com.au
_
checkout how the sharedemail module does it.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.