Skip to main content

Automatically Create a Drupal User After a CiviCRM Contact is Created

One feature that has been lacking in CiviCRM is the ability to create a Drupal user when a contact is NOT created via the new Drupal user form or a CiviCRM profile form. Luckily Skvare has developed a custom extension to solve this problem. 

CiviCRM administrators will often create contacts manually in CiviCRM or import new contacts that will need to log into the site. To do this now, administrators will need to go to each contact and choose “Create CMS User” from the contact’s actions menu. After the contact has been created, the admins need to reach out to the contact and ask that they reset their password, or trigger the password reset email manually. Users may get confused if the admins trigger the email because they didn’t realize that they had an account. So it's recommended that admins also reach out to the contacts and tell them not to be alarmed by the password reset email.

Webform CiviCRM is an increasingly popular module that integrates Drupal Webforms with CiviCRM. Webforms give site builders more control over their forms by tapping into webform features such as reordering fields, validation, and conditional rules. Webform CiviCRM allows users to create contacts and populate CiviCRM data from core CiviCRM fields to CiviCRM custom fields. It can work with contribution / donation forms, event registration forms, and membership sign up forms. The problem is that no user is created when the form is submitted and the site admins resort to the manual process stated above.

To solve this problem, Skvare created the CMS User extension for CiviCRM to provide this functionality and allow the rules to be configured without the help of a developer. Going to /civicrm/admin/cmsuser?reset=1 provides the user interface shown below. A scheduled job (or cron job) runs through contacts of a certain group or tag and creates CMS user accounts. Once the scheduled job creates the user, the contact will be removed from the group or tag so it's not processed again. Since there is a delay in the user account creation, we recommend adding some text to form thank you pages and emails along the lines of “you will receive an email about your new user account in the next X minutes.”

Image

Here is a breakdown of the options:

  • Set a username pattern using CiviCRM tokens. For example {contact.first_name}_{contact.last_name}_{contact.contact_id}
  • Whether or not user should be notified via email when their account has been created
  • Create or select an existing group to reference for the CMS user creation
  • Create or select an existing tag to reference for the CMS user creation
  • Reset CMS Password will reset all user’s passwords within the group or tag defined above.

There are a few common cases where this feature is very handy. Oftentimes CiviCRM contacts are created manually or imported by website admins to store contribution, membership, or participant records. Webforms are also very common for membership sign ups and event registration. Out-of-the-box, CiviCRM Webforms can create contact records, contribution records, membership records, and event participant records, but not user accounts. By automating the user creation process, it reduces the admin’s frustration and their time spent to create contacts, users, and guidance on how the user can set their password.

Download the extension from the link below. If you are looking to expand your website’s capabilities, then contact Skvare for assistance.


https://github.com/Skvare/com.skvare.cmsuser

Share this post