CRM-17029 - Add to Group profile setting wasn't working on petitions
authorJon goldberg <jon@palantetech.coop>
Thu, 11 Feb 2016 22:49:50 +0000 (17:49 -0500)
committerJon goldberg <jon@palantetech.coop>
Thu, 11 Feb 2016 22:49:50 +0000 (17:49 -0500)
CRM/Campaign/Form/Petition/Signature.php

index b7b6ae238a5fab57aec47cb28b6e8eada2667614..00da7287770bb6c0bfe06a29652b3448f5669506 100644 (file)
@@ -495,7 +495,9 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
 
     $transaction = new CRM_Core_Transaction();
 
-    $addToGroupID = isset($this->_addToGroupID) ? $this->_addToGroupID : NULL;
+    // CRM-17029 - get the add_to_group_id from the _contactProfileFields array.
+    $firstField = array_shift(array_slice($this->_contactProfileFields, 0, 1));
+    $addToGroupID = isset($firstField[add_to_group_id]) ? $firstField[add_to_group_id] : NULL;
     $this->_contactId = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_contactProfileFields,
       $this->_contactId, $addToGroupID,
       $this->_contactProfileId, $this->_ctype,