2

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.

3 Answers 3

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 I wrote to handle this exact scenario on Github.

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

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'
  1. 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'
3
  • 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: lab.civicrm.org/dev/core/-/issues/4370 Commented Apr 6 at 17:04
  • 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 ?
    – Klemet
    Commented Apr 8 at 14:56
  • if it doesn't currently, I think that would only take a few minutes to add the Petition entity to Form Builder. Commented Apr 8 at 20:56
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.