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 Profiles (Moderator: Dave Greenberg) »
  • Assign to one or more groups programmatically based on field choice
Pages: [1]

Author Topic: Assign to one or more groups programmatically based on field choice  (Read 704 times)

holmesg

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.4
  • CMS version: Joomla! 2.5.8
  • MySQL version: 5.1.70
  • PHP version: PHP Version 5.3.22
Assign to one or more groups programmatically based on field choice
August 20, 2014, 11:13:16 am
I have a profile form that currently assigns new contacts to one predetermined group, using "Add new contacts to a Group?" in Advanced Settings. (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 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).

How would I go about implementing this?

holmesg

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.4
  • CMS version: Joomla! 2.5.8
  • MySQL version: 5.1.70
  • PHP version: PHP Version 5.3.22
Re: Assign to one or more groups programmatically based on field choice
August 21, 2014, 07:13:23 am
Any thoughts?

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

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: Assign to one or more groups programmatically based on field choice
August 21, 2014, 09:55:44 am
have you tried creating Smart Groups and basing the Smart Groups off the responses? That seems the best and easiest option.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Assign to one or more groups programmatically based on field choice
August 21, 2014, 12:49:45 pm
I agree with FrTommy - Smart Groups could be your solution unless you then need to do something that rules them out. The approach suggested is a standard way of creating eg 'issue' based Mailing Lists.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

holmesg

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.4
  • CMS version: Joomla! 2.5.8
  • MySQL version: 5.1.70
  • PHP version: PHP Version 5.3.22
Re: Assign to one or more groups programmatically based on field choice
August 22, 2014, 10:10:34 am
Thank you both.

It sounds like a good idea, however in some cases (for some of the possible choices on the form), the group we want to assign them to is pre-existing, i.e. a regular group. 

Is there a way to assign people to a regular group automatically when they show up in a particular smart group?

Hmm; I might be able to do what the client wants by assigning the normal group as a parent group of the corresponding smart group.
« Last Edit: August 22, 2014, 11:23:50 am by holmesg »

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Assign to one or more groups programmatically based on field choice
August 22, 2014, 03:13:17 pm
Would it be easier to think the other way round, and add the people 'already in a Standard Group' to a Smart Group?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: Assign to one or more groups programmatically based on field choice
August 23, 2014, 08:50:10 am
That's what I was going to say too, petednz. Recreate your regular group as a smart group and then use the smart group.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Assign to one or more groups programmatically based on field choice

This forum was archived on 2017-11-26.