Skip to content

5.0 Newsletter Subscription

Before beginning, check that Enable Double Opt-in for Profile Group(s) field is enabled. In CiviCRM, got to Administration>CiviMail>CiviMail Component Settings

alt screenshot of CiviMail Component Setting

As people sign up, you want to add them to a group.

To create a group, go to CiviCRM>Contacts>New Group

Group title: Give you group a title. In this example we've used Newsletter Webform SignUp

Group Type: Mailing List

Visibility: Public Pages

Is Active: should be checked

alt screenshot of CiviCRM Newsletter Group

Now you are ready to create your webform as shown in Basic Webform

CiviCRM Configuration Form

Open your basic webform - Structure > Webform > Basic Webform > Settings > CiviCRM

We have enabled first name, last name and e-mail fields.

alt screenshot of CiviCRM Configuration Settings

alt screenshot of CiviCRM Configuration Settings

In the Tags and Groups Field Box you want to change it from No to Yes.

alt screenshot of CiviCRM Newsletter Group

This will allow you to select your group from the dropdown menu

alt screenshot of CiviCRM Newsletter Group

Under the Additional Options section on the left, you want to make sure Confirm Subscriptions is selected

alt screenshot of CiviCRM Configuration Settings

View

Let’s take a look at how the form looks right now. Select View

alt screenshot of CiviCRM Newsletter SignUp

Build

And this is what our build elements look like

alt screenshot of CiviCRM Newsletter SignUp

Test

We can then select Test and see how the form will look like when it is filled out. After clicking submit, be sure to check your CiviCRM database to see that the data landed in the correct fields.

alt screenshot of CiviCRM Newsletter SignUp Test

Form YAML

civicrm_1_contact_1_fieldset_fieldset:
  '#type': fieldset
  '#title': 'Contact 1'
  '#form_key': civicrm_1_contact_1_fieldset_fieldset
  civicrm_1_contact_1_contact_first_name:
    '#type': textfield
    '#contact_type': individual
    '#form_key': civicrm_1_contact_1_contact_first_name
    '#extra':
      width: 20
    '#parent': civicrm_1_contact_1_fieldset_fieldset
    '#title': 'First Name'
  civicrm_1_contact_1_contact_last_name:
    '#type': textfield
    '#contact_type': individual
    '#form_key': civicrm_1_contact_1_contact_last_name
    '#extra':
      width: 20
    '#parent': civicrm_1_contact_1_fieldset_fieldset
    '#title': 'Last Name'
  civicrm_1_contact_1_email_email:
    '#type': email
    '#form_key': civicrm_1_contact_1_email_email
    '#extra':
      width: 20
    '#parent': civicrm_1_contact_1_fieldset_fieldset
    '#title': Email