Answers.Body: <p><strong>Yes</strong>.  You can add "Groups" as a field to a CiviCRM Profile.  There's similar functionality available on Webform.</p>
  
  <p>If you use profiles, only groups with the Visibility setting of "Public Pages" will be available for the petition signer to click.  If you use Webform, you can modify the widget to show a specific set of groups for that webform.</p>
  
  <p>Note that the profile implementation has a limitation - if someone a) fills in a profile that has the "Groups" field, b) is already in your database, c) is already a member of one of the public groups, and d) does not check off the box for that group, they will be REMOVED from the group.</p>
  
  <p>If that last part is a problem, and you're up for writing a custom extension, you can see a <a href="https://github.com/MegaphoneJon/coop.palantetech.module.cpehn.joinnetworkcheckbox/blob/master/joinnetworkcheckbox.php" rel="nofollow noreferrer">quick and dirty implementation</a> I wrote to handle this exact scenario on Github.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-01T15:59:41.417Z
Answers.LastActivityDate: 2017-11-01T15:59:41.417Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>I'm digging up an old post, but I had the same issue and wanted to share the solution we found for future users.</p>
  <p>Note that this method solves two problems : it makes it easier to integrate a subscribe option in your form (no need to display public groups), and it solves the issue of not wanting a contact to be able to un-subscribe via the petition if they tick &quot;No&quot;.</p>
  <p>We solved this by using the CiviRules extension, which can be installed easily through <code>Administer</code> =&gt; <code>System Settings</code> =&gt; <code>Extensions</code> =&gt; <code>Add New</code>.</p>
  <p>Next, we create a new group of custom fields in <code>Administer</code> =&gt; <code>Customize Data and Screens</code> =&gt; <code>Custom Fields</code>. We make two fields : one that will be displayed as a Yes or No at the end of the petition to subscribe, and one to indicate that the subscription status is pending (important to not send two mails of subscription activation !).</p>
  <p>After that, you should find the two fields on your contact pages like on this image.</p>
  <p><a href="https://i.sstatic.net/fcL5r.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fcL5r.png" alt="Image of the two custom fields on the contact page" /></a></p>
  <p>Then, go to <code>Administer</code> =&gt; <code>CiviRules</code> =&gt; <code>Manage rules</code>. In there you gotta create 2 rules to make sure that when your contact says &quot;Yes&quot; to the variable indicating a petition subscription (and that he's not already in your newsletter group), then he'll be added.</p>
  <p>Here are the rules in detail :</p>
  <ol>
  <li>Newsletter subscription after petition (Contact already exists)</li>
  </ol>
  <p>With this rule, an existing contact that signs the petition but wasn't in the mailing list will be added as &quot;pending&quot; (and will thus receive the confirmation email for the subscription). The <code>Pending Petition Newsletter Subscription</code> variable is here to prevent the rule from re-triggering itself, as adding the contact to the group counts as a contact change. This prevents the rule from sending a second email of confirmation for your mailing list.
  This rules also works when a new contact is created, even though the trigger is &quot;Contact changed&quot;.</p>
  <pre><code>Linked Trigger
  Contact of any type is changed 
  
  
  Linked Condition(s)
   
          Field Value Comparison  Contact.Newsletter Subscription Petition = 1
  AND     Field Value Comparison  Contact.Pending Petition Newsletter Subscription = 0 
  AND     Contact (not) in Group(s)   Not in selected groups (newsletter mailing list) 
  
  
  Linked Action(s)
       
  Create Pending Group Subscription   Subscribe contact to group(s): newsletter mailing list 
  Set Custom Field on contact     Set 'Pending Petition Newsletter Subscription' to 'Yes'
  </code></pre>
  <ol start="2">
  <li>Remove &quot;Pending&quot; status variable for petition newsletter subscription once group is joined</li>
  </ol>
  <p>This rule removes the pending status. Not vital, but only used for the case where the contact un-subscribes from the group and wants to re-subscribe through the petition form.</p>
  <pre><code>Linked Trigger
  Contact is added to Group 
  
  
  Linked Condition(s)
  
          Field Value Comparison  Contact.Newsletter Subscription Petition = 1
  AND     Field Value Comparison  Contact.Pending Petition Newsletter Subscription = 1    
  AND     Contact (not) in Group(s)   In one of selected groups (newsletter mailing list) 
  
  
  Linked Action(s)     
  Set Custom Field on contact     Set 'Pending Petition Newsletter Subscription' to 'No'
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-06T17:04:25.047Z
Answers.Text: While creating custom fields for this isn't ideal, this is the first time I've seen this problem solved comprehensively without code.
  
  Note that there is a discussion underway to make sure that FormBuilder can solve these issues once and for all: https://lab.civicrm.org/dev/core/-/issues/4370
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-08T14:56:05.753Z
Answers.Text: Yeah, I'm happy that we did that without code !
  It's interesting to see that updates to FormBuilder are coming for this; although I'm unsure as if it would solve the issue of petitions. Can FormBuilder be used for petition signing ?
Answers.UserDisplayName: Klemet
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-08T20:56:19.927Z
Answers.Text: if it doesn't currently, I think that would only take a few minutes to add the Petition entity to Form Builder.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-05T16:44:32.793Z
Answers.LastActivityDate: 2024-04-05T16:44:32.793Z
Answers.UserDisplayName: Klemet
Answers.Body: <p>It sounds like you are using Drupal. In which case, via Webforms integration, set Groups (on Contact 1 presumably) to 'user selects. Then in the webform component, edit Groups and select only those Groups you want listed and configure so they show as checkboxes. That should get you what you want.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-01T21:09:00.590Z
Answers.LastActivityDate: 2017-11-01T21:09:00.590Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>We're a political organisation running CiviCRM 4.6 looking to make public campaign pages about local issues.</p>
  
  <p>On these pages a site visitor should be able to:
   - Enter their name, postcode, email address
   - Often fill out a personalised message
   - Opt in to a mailing list on this campaign</p>
  
  <p>With all this data being stored in Civi.</p>
  
  <p>This feels like a CiviPetition, although I am struggling with the implementation.</p>
  
  <ul>
  <li>Is it possible to have a checkbox in a CiviCRM Profile/Webform that, if selected, will add someone to a Mailing List Group?</li>
  </ul>
  
  <p>I assume something is possible with Rules but I do not want to have to make custom rules for each webform. Trying to make creation of new petitions/campaigns as easy as possible.</p>
  
Tags: <civimail><webform-civicrm><mailing><civicampaign><civisurvey>
Title: CiviMail Mailing List opt-in checkboxes?
ThreadText: # CiviMail Mailing List opt-in checkboxes?
  
  (Asked by: username_0 on 2017-11-01)
  
  We're a political organisation running CiviCRM 4.6 looking to make public campaign pages about local issues.
  
  On these pages a site visitor should be able to:
  - Enter their name, postcode, email address
  - Often fill out a personalised message
  - Opt in to a mailing list on this campaign
  
  With all this data being stored in Civi.
  
  This feels like a CiviPetition, although I am struggling with the implementation.
  
  * Is it possible to have a checkbox in a CiviCRM Profile/Webform that, if selected, will add someone to a Mailing List Group?
  
  I assume something is possible with Rules but I do not want to have to make custom rules for each webform. Trying to make creation of new petitions/campaigns as easy as possible.
  
  **Tags:** civimail, webform-civicrm, mailing, civicampaign, civisurvey
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2017-11-01. Score: 3
  
  **Yes**. You can add "Groups" as a field to a CiviCRM Profile. There's similar functionality available on Webform.
  
  If you use profiles, only groups with the Visibility setting of "Public Pages" will be available for the petition signer to click. If you use Webform, you can modify the widget to show a specific set of groups for that webform.
  
  Note that the profile implementation has a limitation - if someone a) fills in a profile that has the "Groups" field, b) is already in your database, c) is already a member of one of the public groups, and d) does not check off the box for that group, they will be REMOVED from the group.
  
  If that last part is a problem, and you're up for writing a custom extension, you can see a [quick and dirty implementation](https://github.com/MegaphoneJon/coop.palantetech.module.cpehn.joinnetworkcheckbox/blob/master/joinnetworkcheckbox.php) I wrote to handle this exact scenario on Github.
  
  
  ---
  
  ### Answer by username_2 on 2024-04-05. Score: 2
  
  I'm digging up an old post, but I had the same issue and wanted to share the solution we found for future users.
  
  Note that this method solves two problems : it makes it easier to integrate a subscribe option in your form (no need to display public groups), and it solves the issue of not wanting a contact to be able to un-subscribe via the petition if they tick "No".
  
  We solved this by using the CiviRules extension, which can be installed easily through `Administer` => `System Settings` => `Extensions` => `Add New`.
  
  Next, we create a new group of custom fields in `Administer` => `Customize Data and Screens` => `Custom Fields`. We make two fields : one that will be displayed as a Yes or No at the end of the petition to subscribe, and one to indicate that the subscription status is pending (important to not send two mails of subscription activation !).
  
  After that, you should find the two fields on your contact pages like on this image.
  
  [![Image of the two custom fields on the contact page](https://i.sstatic.net/fcL5r.png)](https://i.sstatic.net/fcL5r.png)
  
  Then, go to `Administer` => `CiviRules` => `Manage rules`. In there you gotta create 2 rules to make sure that when your contact says "Yes" to the variable indicating a petition subscription (and that he's not already in your newsletter group), then he'll be added.
  
  Here are the rules in detail :
  
  1. Newsletter subscription after petition (Contact already exists)
  
  With this rule, an existing contact that signs the petition but wasn't in the mailing list will be added as "pending" (and will thus receive the confirmation email for the subscription). The `Pending Petition Newsletter Subscription` variable is here to prevent the rule from re-triggering itself, as adding the contact to the group counts as a contact change. This prevents the rule from sending a second email of confirmation for your mailing list.
  This rules also works when a new contact is created, even though the trigger is "Contact changed".
  
  ```
  Linked Trigger
  Contact of any type is changed 
  
  Linked Condition(s)
   
          Field Value Comparison  Contact.Newsletter Subscription Petition = 1
  AND     Field Value Comparison  Contact.Pending Petition Newsletter Subscription = 0 
  AND     Contact (not) in Group(s)   Not in selected groups (newsletter mailing list) 
  
  Linked Action(s)
       
  Create Pending Group Subscription   Subscribe contact to group(s): newsletter mailing list 
  Set Custom Field on contact     Set 'Pending Petition Newsletter Subscription' to 'Yes'
  
  ```
  
  2. Remove "Pending" status variable for petition newsletter subscription once group is joined
  
  This rule removes the pending status. Not vital, but only used for the case where the contact un-subscribes from the group and wants to re-subscribe through the petition form.
  
  ```
  Linked Trigger
  Contact is added to Group 
  
  Linked Condition(s)
  
          Field Value Comparison  Contact.Newsletter Subscription Petition = 1
  AND     Field Value Comparison  Contact.Pending Petition Newsletter Subscription = 1    
  AND     Contact (not) in Group(s)   In one of selected groups (newsletter mailing list) 
  
  Linked Action(s)     
  Set Custom Field on contact     Set 'Pending Petition Newsletter Subscription' to 'No'
  
  ```
  
  > **Comments:**
  > **username_1**: While creating custom fields for this isn't ideal, this is the first time I've seen this problem solved comprehensively without code.  Note that there is a discussion underway to make sure that FormBuilder can solve these issues once and for all: https://lab.civicrm.org/dev/core/-/issues/4370  
  > **username_2**: Yeah, I'm happy that we did that without code ! It's interesting to see that updates to FormBuilder are coming for this; although I'm unsure as if it would solve the issue of petitions. Can FormBuilder be used for petition signing ?  
  > **username_1**: if it doesn't currently, I think that would only take a few minutes to add the Petition entity to Form Builder.  
  
  ---
  
  ### Answer by username_3 on 2017-11-01. Score: 1
  
  It sounds like you are using Drupal. In which case, via Webforms integration, set Groups (on Contact 1 presumably) to 'user selects. Then in the webform component, edit Groups and select only those Groups you want listed and configure so they show as checkboxes. That should get you what you want.
  
  
  ---
  
  