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 »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Getting a better understanding of matching Drupal & Civi records
Pages: [1]

Author Topic: Getting a better understanding of matching Drupal & Civi records  (Read 1791 times)

tkrajcar

  • Guest
Getting a better understanding of matching Drupal & Civi records
October 20, 2009, 05:14:59 pm
Hi all,

We are doing a project of a members-only website that uses CiviCRM as the membership manager. In our use case, users will be Civi contacts first, and Drupal users second. They CANNOT simply register for a Drupal account - they must register through Civi, pay up, and then gain access via a manual approval process (their membership app needs to be examined and vetted by a member services staff before approval).

Basically, I need to create a Drupal account when a user gets approved, and make sure its Drupal roles get manipulated according to their membership status - when their membership expires if they haven't renewed, the roles need to get pulled, etc.

I have all of this figured out how I'm going to work it decently well. I can use the Drupal user API to create users, I have a custom Drupal profile field for the civi contact ID, which lets my views pull Civi data, and I have a table I'm going to add to the Civi database where I can store 'signup tokens' (one-time-use tokens that I can email to users after they're approved so they can sign up for their Drupal account) and also store the newly-created Drupal user ID just in case I need to know it.

I looked at the Drupal Roles Sync module, but I don't really understand how it knows which Drupal user is which Civi contact. Can anyone explain how this matching is done?

Similarly, the one thing that I'm not sure how to do in my current model is renewals. When a Drupal user is logged in and visits the Civi contribution pages, Civi needs to know who they are. Right now this happens automatically for some accounts (I inherited this project, so I'm not sure how they were set up) and doesn't for others. How can I help Civi make this association? Is there a URL variable or something similar I can provide, or another solution?

I've seen that there is some functionality in Civi to automatically create contacts for all existing Drupal users (and I think that's how the linking has been done for the few accounts that already exist) but that won't work for me going forward because I need people to be in Civi first, not Drupal first.

Thanks for any input you can help with.

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: Getting a better understanding of matching Drupal & Civi records
October 20, 2009, 07:52:48 pm

1. check the table:civicrm_uf_match this stores the link between a drupal user and civicrm contact

2. the function "Synchronize Users to Contacts" uses and populates the above table (http://drupal.demo.civicrm.org/civicrm/admin/synchUser?reset=1)

3. When a user is created with the same civicrm email address, civicrm does the right matching (via hook_user) and fills the civicrm_uf_match table

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

secularaugust

  • I’m new here
  • *
  • Posts: 26
  • Karma: -1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.1.41-3ubuntu12.10
  • PHP version: 5.3
Re: Getting a better understanding of matching Drupal & Civi records
December 03, 2009, 12:52:48 pm
So I'm aware of the Synchronize Users-to-Contacts function (http://wiki.civicrm.org/confluence/display/CRMDOC/Synchronize+Users-to-Contacts).  And I'm also aware that civicrm_uf_match is where the links between users and contacts are kept.  I'm wondering if there is a built-in way to link only selected contacts to users.

I have a Drupal install that we've been using since 2005.  We wrote a custom membership module to make some users members.  I want to import all those members into CiviCRM as contacts, but I don't want the non-member users to create contacts... most of them are long-abandoned accounts that people created to post one comment or the like.  I am happy to write a script to insert all of the right data into civicrm_uf_match.  I just don't want to reinvent the wheel or break something by doing this.

I tried importing the Drupal id for the members in the external_identifier field... the numbers imported fine, but create no link between the contact and the Drupal users that I could see.  I wasn't really expecting this to work, but I figured it was worth a shot.

Thanks!

(I know I'm posting this on an old thread... seemed to make more sense than starting a new one as this is all related.  Let me know if I have sinned and I'll start creating new threads.)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Getting a better understanding of matching Drupal & Civi records

This forum was archived on 2017-11-26.