Answers.Body: <p>As you may already know, there is a field that will expose all groups that are mailing lists to the user and let them select, which one they want to subscribe to. You could add this field to the profile that you use for events. It is descirben on <a href="http://book.civicrm.org/user/current/email/setup/" rel="nofollow">this page</a> (see "Using a profile"). However, users would be presented with all public mailing groups available.</p>
  
  <p>As an alternative, you could also create a custom field (I would recommend a contact field but you could also use an event field) and give the users the opportunity to tick that field/option. You could then create a smart (mailing) group (which is also described on the page linked above) that includes all people who selected the option.</p>
  
  <p>Both options do not require any coding at all and can be done via the UI.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T11:19:40.083Z
Answers.LastActivityDate: 2015-08-03T11:19:40.083Z
Answers.UserDisplayName: Fabian
Body: <p>I want to create a custom field that selects a CiviCRM group.</p>
  
  <p>eg, the business logic is "when a person registers for an event and they select 'subscribe me to news of events like this' then add them to group X" where X is a custom field attached to the event.</p>
  
  <p>I could create a custom field that is an integer, look up the Id of the group, and set the custom field to that number. It would be nicer to have a UI for that.</p>
  
  <p>Any pointers? Cheers!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-03T08:30:42.117Z
Comments.Text: Perhaps http://civicrm.stackexchange.com/questions/3638/creating-a-custom-select-field-and-update-option-values-from-php answers my question
Comments.UserDisplayName: Ken West
Tags: <custom-fields>
Title: How do I create a custom field that selects a CiviCRM group
ThreadText: # How do I create a custom field that selects a CiviCRM group
  
  (Asked by: username_0 on 2015-08-03)
  
  I want to create a custom field that selects a CiviCRM group.
  
  eg, the business logic is "when a person registers for an event and they select 'subscribe me to news of events like this' then add them to group X" where X is a custom field attached to the event.
  
  I could create a custom field that is an integer, look up the Id of the group, and set the custom field to that number. It would be nicer to have a UI for that.
  
  Any pointers? Cheers!
  
  **Tags:** custom-fields
  
  > **Comments:**
  > **username_0**: Perhaps http://civicrm.stackexchange.com/questions/3638/creating-a-custom-select-field-and-update-option-values-from-php answers my question  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-03. Score: 3
  
  As you may already know, there is a field that will expose all groups that are mailing lists to the user and let them select, which one they want to subscribe to. You could add this field to the profile that you use for events. It is descirben on [this page](http://book.civicrm.org/user/current/email/setup/) (see "Using a profile"). However, users would be presented with all public mailing groups available.
  
  As an alternative, you could also create a custom field (I would recommend a contact field but you could also use an event field) and give the users the opportunity to tick that field/option. You could then create a smart (mailing) group (which is also described on the page linked above) that includes all people who selected the option.
  
  Both options do not require any coding at all and can be done via the UI.
  
  
  ---
  
  