CiviCRM Contacts in Drupal 8

Published
2020-05-26 09:34
Written by
W01F - member of the CiviCRM community - view blog guidelines

Today we are going to explore a common use case for how CiviCRM contacts can integrate with Drupal users using the CiviCRM Entity module

Managing contacts can be a daunting task for organizations, including many of our clients here at Skvare. With needs that include membership subscriptions, group emails, accepting donations, relationships to other contacts and organizations, and more - thankfully, CiviCRM answers each of these in a straightforward and user-friendly way.

And by pairing with Drupal we enable custom user profiles, and any combination of contact-content referencing, while making use of advanced media features and display options.

So before we dive in, how do we connect CiviCRM contacts and Drupal users?

Please note that all synced contacts are for “Individual” contact types and subtypes within CiviCRM. Organizations (and Households) are thought of as “person-less” contacts.

When a new user is registered in Drupal, through either a standard Drupal registration form or a CiviCRM-enabled profile webform, a contact is automatically created in CiviCRM with the same contact information and address.

The new contact can then be found and managed within CiviCRM.

The other direction works as well!

You can create a new contact in CiviCRM and then synchronize by selecting “Create User Record” from the contact “Actions” option. This will create a new Drupal user for the new contact.

There are several other methods to import and sychronize users and contacts. Edit media Image

Bulk import users into Drupal using CSV Migration

After successfully importing users, from the CiviCRM menu you can choose to “Synchronize Users to Contacts”. This will automatically generate CiviCRM contact records for any unpaired Drupal users.

This use case can be especially helpful where CiviCRM was installed on an existing Drupal system, or when large collections of users need to be migrated with several fields intended to kept within Drupal.

Bulk import contacts into CiviCRM using Import Contacts. Stay tuned for our upcoming three-part blog series on importing contacts for a step-by-step tutorial on this method!

Using this method, you can set up a View Bulk Operation to create users for all contacts that meet criteria set up within your view.

What can I do with my synced users now?

Now that we have our users, let’s look at a simple use case where the CiviCRM Entity module allows us to use contact data within a Drupal setting.

We’re going to create a few contacts, and then construct a view to display CiviCRM contact data and Drupal user field information. Many of our clients at Skvare use this functionality in production on their Drupal 7 and 8 sites to display their contact data.

First we’ll add a few users… and then we’ll add some Drupal-specific fields, such as an image using the core media module...

Then we’ll set up the view. We’ll need to add a relationship to our CiviCRM contacts - this will allow us to access our contact fields the same as any other native Drupal field. Then we’ll add both our types of fields, and style how we would normally.

For this demonstration I’m going to create a copy of the standard “People” view in Drupal.

And... Congratulations!

You now have a view featuring data sourced from both CiviCRM and Drupal entities side by side. Edit media Image

Our next blog is a personal favorite - we will create an interactive map using the CiviCRM address field with the CiviCRM Entity module!

If there is a specific use case you would like to inquire about or explore, please feel free to bring it up in one of the upcoming open forum webinars, or reach out to our expert team directly for a free consult!

For more information, you can read our CiviCRM Entity information page or visit the module homepage to review and install!

Quick links

Original blog: CiviCRM Contacts in Drupal

< Previous: Unleashing the CiviCRM Entity Module in Drupal 8

> Next: Interactive Maps with CiviCRM Addresses