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
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
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.
In the Tags and Groups Field Box you want to change it from No to Yes.
This will allow you to select your group from the dropdown menu
Under the Additional Options section on the left, you want to make sure Confirm Subscriptions is selected
View¶
Let’s take a look at how the form looks right now. Select View
Build¶
And this is what our build elements look like
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.
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