drupal-7civicrm

Drupal 7 CiviCRM - Assign contact to one or more groups programmatically based on field choice


I have a profile form that currently assigns new contacts to one predetermined group, using "Add new contacts to a Group?" in Advanced Settings for that profile. (Let's call it the "People Who Submit That Form" group for the sake of discussion).

However, I would like to assign the new contact to one or more additional groups, based on their response to a question in the profile form .

One of the questions on the profile is "I am interested in:" with a list of checkbox choices. What I would like to make happen is if they choose X, Y, and Z, then I want their contact to also be assigned to the X, Y, and Z groups in CiviCRM. If they only choose X and Z, then their contact should only be assigned to the X and Z groups (the names of the choices and the names of the groups do not match exactly, but you see the idea, there is a one to one correspondence).

I looked at CiviCRM Rules Integration, but there aren't any events for "profile form has been submitted".

How would I go about implementing this?


Solution

  • I solved the problem with smart groups. Do an Advanced Search, find contacts who had selected a specific answer for the custom field in question, select all contacts found and create a smart group.

    Then to get them (functionally) into existing civicrm groups, I assigned the existing group as a parent of the smart group.