CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Drupal users from CiviCRM contacts, multiple contacts have same email address
Pages: [1]

Author Topic: Drupal users from CiviCRM contacts, multiple contacts have same email address  (Read 3558 times)

rjlang

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3.19
Drupal users from CiviCRM contacts, multiple contacts have same email address
April 11, 2010, 09:17:00 pm
Hi,

We're setting up a members-only space on our website, where we want to allow logged-in Drupal users who have current CiviCRM memberships to have access to certain pages. So far, we've got most everything working, using the CiviMember Roles Sync module, and we're at the stage of having to create Drupal Users for all current CiviCRM Members (about 1000 members). But we've run into an issue: we have multiple Individual Contacts with the same email address (and they can't be merged; they have different names and correspond to different CiviCRM Memberships).

So we know that Drupal users must have unique email addresses. We're fine with that, that just means that only one of the contacts gets to have a Drupal user account, and that's OK. But the problem that arises is: when we create a Drupal User (e.g., via User Import), how can we make sure it gets "connected" to the *right* CiviCRM contact with that email address? (Would be great if User Import allowed one to specify the CiviCRM Contact ID to use for matching.) Any ideas?

Thanks,

Robert

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
April 12, 2010, 08:28:26 am

how about you do the user import and then basically go in and fix the civicrm_uf_match tables to ensure your drupal user / civicrm contact records match as you prefer. Might be an easier / quicker solution

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

speejay

  • Guest
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
April 12, 2010, 11:34:01 am
So the "Synchronize Users to Contacts" button only syncs drupal users to civi contacts?  There is not a utility that will do the reverse??

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
April 12, 2010, 12:05:32 pm
You can use the User IMport - a drupal module - and spit out emails and names from civicrm and then import them to create Drupal accounts matching on emails.

If you have multiple civi contacts with same email, then remove the ones you are wanting to avoid before using User Import
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

rjlang

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3.19
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 06, 2010, 12:32:45 pm
Hi. We found a workaround for this problem back when I originally posted in April, but we keep having the issue arise: we have multiple Civi contacts with the same email address, and we can't just delete contacts that have dupe emails; they have things like event registrations and memberships attached to them that their owners would not want to see go away.

So when a person creates a Drupal user account (or we use User Import) and match on the email address, CiviCRM picks one of the contacts to sync it to. Not always the right one. (Incidentally, if Drupal User Import allowed Contact ID as a matching field, that would be really great.)

So the problem now is that some Drupal users are linked to the wrong CiviCRM contacts.

Lobo suggested:

Quote
how about you do the user import and then basically go in and fix the civicrm_uf_match tables to ensure your drupal user / civicrm contact records match as you prefer. Might be an easier / quicker solution

I'd be willing to pursue that, but is there a way through the web interface of CiviCRM that these tables are exposed to viewing/editing? Like, if I were editing a CiviCRM contact and could enter the Drupal user ID of the desired Drupal user, that would be perfect. But I don't see that anywhere. Or is something that requires editing MySQL tables directly?

Robert

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 06, 2010, 12:52:41 pm
Quote from: rjlang on August 06, 2010, 12:32:45 pm
I'd be willing to pursue that, but is there a way through the web interface of CiviCRM that these tables are exposed to viewing/editing? Like, if I were editing a CiviCRM contact and could enter the Drupal user ID of the desired Drupal user, that would be perfect. But I don't see that anywhere. Or is something that requires editing MySQL tables directly?

you can do the above by extending the Edit form via hooks (buildForm/postProcess) and allowing an admin to set the right match between a drupal user and civicrm contact. check:

http://en.flossmanuals.net/CiviCRM/DevelopIntro
http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

alternatively you can manipulate that table directly in mysql

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

rjlang

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3.19
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 06, 2010, 07:51:07 pm
Hi Lobo, thanks for the quick answer. I'm going to have to do a bunch of study to figure out how to extend the Edit form, I guess. We need a way for an admin to make this sort of change via a user-friendly interface, so direct editing of the SQL whenever this arises isn't workable. I'll look through those links you gave.

Just to check my understanding is the user/contact sync data stored entirely on the CiviCRM side? Drupal doesn't keep its own record of which contact goes with which user?

And, having looked at the SQL, I think I understand what's going on, but just want to check: in table civicrm_uf_match, field uf_id is the Drupal user ID; field contact_id is the CiviCRM contact ID; and those are the only two fields that need to be edited to alter which Drupal user goes with which CiviCRM contact, nothing else?

Thanks in advance,

Robert

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 06, 2010, 08:01:29 pm

both your statements are correct :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 06, 2010, 08:21:02 pm
In terms of importing users & linking to contact records - if there is any way to add uf_match records by API (I haven't checked) then the civimigrate method (which I wrote a blog about recently) would facilitate importing users & linking them to contacts.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

rjlang

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3.19
Re: Drupal users from CiviCRM contacts, multiple contacts have same email address
August 07, 2010, 12:05:51 pm
Thanks, lobo. The way seems clear from here.

Robert

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Drupal users from CiviCRM contacts, multiple contacts have same email address

This forum was archived on 2017-11-26.