This module syncs contacts from civicrm to user records in a Drupal website. The civicrm does not need to be installed in this drupal website.
It does this by calling the api from the Cange Messages extension
- cmrf_core: https://github.com/CiviMRF/cmrf_core
- Install cmrf_core (https://github.com/CiviMRF/cmrf_core)
- Configure cmrf_core
- Install this module
- Configure the module at admin/config/civimrf/civimrf_message_queue_user_sync
- Dont forget to setup a cron job for your drupal site
Below is a screen shot of the configuration screen:
You can configure which api you want to use for syncing contacts to users. In the screenshot you see we have a custom api You can also configure which field from the api goes to the drupal username, email, uid field.
The uid field is defined by this module and is used to store the contact id (or another unique identifer).
Each time the cron runs the user sync will determine how many contacts from civicrm need to be synced to Drupal. A batch is created which synchronizes 100 contacts. After all contacts are synchronized contacts who are in the system but not in the synchronisation are deleted.
When a new user record is created a user receives the email to reset his/her password. If you want you can change the text of this email. You can do this under Configuration --> Account Settings --> Welcome (new user created by administrator)
When an existing user is deleted the user receives an email stating his/her account has been cancelled. If you want you can change the text of this email. You can do this under Configuration --> Account Settings --> Account cancelletion confirmation
This module provides the following hooks
hook_civimrf_message_queue_user_update_alter
hook_civimrf_message_queue_user_new_alter
Below an example implemntation of those hooks. In this example the api used returns the team_id (which is the contact id of the team record in CiviCRM). We want to store this team_id on the user record in Drupal.
function roparun_team_portal_civimrf_message_queue_user_update_alter(&$edit, $contact) {
if (isset($contact['team_id'])) {
$edit['roparun_team_portal_team_id']['und'][0]['value'] = $contact['team_id'];
}
}
function roparun_team_portal_civimrf_message_queue_user_new_alter(&$edit, $contact) {
if (isset($contact['team_id'])) {
$edit['roparun_team_portal_team_id']['und'][0]['value'] = $contact['team_id'];
}
}