How to use the double opt-in for Contact Form 7 (v2.11)
Marc Wagner
June 14, 2021
With our plugin Forge12 Double-Opt-in for Contact Form 7 you extend the Contact Form 7 WordPress plugin with an additional opt-in system (DOI).
For this, only a few simple steps are needed to convert your form(s) to WordPress forms.
Install Double-Opt-in Plugin #
First, the plugin must be installed via the WordPress Plugin Manager. To do this, simply go to the backend of your WordPress website to the Plugins’ menu item and select the Installation menu item in the sub-navigation (WordPress Dashboard > Plugins > Install).
Use the Upload Plugin button to upload the plugin to your server.
Then click on the “Activate” button to register the Contact Form 7 Double-Opt-in plugin with WordPress.
Configure double opt-in #
After installing the plugin, your Contact Form 7 forms, new settings are available (Forms > Contact Forms > [any_form] > Double-Opt-in).
To enable opt-in for one or more of your forms, first go to the form’s settings (Forms > Contact forms > [any_form]). There you will find a new tab called Double-Opt-in.
There you can define all important settings for the double opt-in procedure.
Parameter | Description |
Enable | By setting the checkbox, the double opt-in for the form is activated. |
Category | This option allows you to set a category for all opt-ins made through this form. All opt-ins will then be assigned to this category. The category can be created via the opt-in settings. |
Dynamic Condition | This field helps you to activate the opt-in only when a checkbox is set or a field is filled in. The system will then automatically switch between an opt-in form and a standard form. |
Confirmation Page | The checkbox allows you to set a custom confirmation page that will be displayed to the visitor after performing the opt-in. |
To | In this field, the placeholder for the Contact Form 7 tag of the opt-in recipient must be specified. E.G.: [email], [your-email]. |
From | This field allows you to specify a custom sender. If you do not enter a sender here, the WordPress default settings will be used. Example: Max Mustermann <[_site_admin_email]> or [_site_title] <[_site_admin_email]> or Max Mustermann <[email protected]> |
Subject | The subject of the opt-in email. |
Template | An email template for the opt-in mails can be selected with a click. Alternatively, an individual HTML can be created in the message body. |
Message Body | The content of the double opt-in mail. HTML can also be used here. For the double opt-in to work, the shortcode [doubleoptinlink] must be integrated as a link, e.g.: &st;a href=”[doubleoptinlink]”>Bestätigen&st;/a> Shortcode: [doubleoptinlink] This automatically generates the confirmation link for the double opt-in. |
Furthermore, in addition to the standard Contact Form 7 tags, additional shortcodes are available for use in the message body:
WordPress Shortcode | Description |
[doubleoptinlink] | Creates the link responsible for executing the opt-in. |
[doubleoptin_form_url] | Contains the path to the form filled in by the visitor to start the opt-in process. |
[doubleoptin_form_subject] | The subject of the double opt-in form. |
[doubleoptin_form_date] | The date when the opt-in was performed. |
[doubleoptin_form_time] | The time when the opt-in was performed. |
[__site_admin_email] | The WordPress email address |
Contact Form 7 Tags | All Contact Form 7 fields are also available for the opt-in email. |
How the double opt-in system works #
Activating the double opt-in system also changes the behavior of the form.
User confirms double opt-in
These steps are executed in case the user confirms the double opt-in:
- Double opt-in mail is sent
- Visitor confirms the double opt-in link
- Double opt-in information is stored
- Normal e‑mail (1) is sent
- Normal e‑mail (2) will be sent — if this has been activated.
User does not confirm double opt-in
These steps are performed in case the user does not confirm the double opt-in:
- Double opt-in mail is sent
- Visitor does not confirm the link within 7 days
- Data will be deleted
Old data will be deleted automatically by a WP cron job after the time you selected. You have several options to choose from here.
What data is stored #
A double opt-in must be logged. This ensures that the e‑mail can really be assigned to the recipient.
For this purpose, our plugin stores some information. The information can be viewed at any time via Tools / Forge12 Double-Opt-in.
Parameter | Description |
Form ID | The link and ID for which the user has given consent. |
E‑Mail | The email used by the visitor when filling out the form. |
Registration Date | The date and time the form was filled out. |
Registration IP | The IP address with which the visitor filled in and sent the form. |
Confirmation Date | The date and time the visitor clicked on the confirmation link. |
Confirmation IP | The IP address with which the visitor confirmed the double opt-in. |
Confirmed | Yes/No — Indicates whether the double opt-in was confirmed by the recipient. |
Opt-Out Date | The date when the visitor unsubscribed from the opt-in through the opt-out system. |
Opt-Out IP | The IP address with which the visitor performed the opt-out. |
Form Fields | The field label and the content of the fields of the form. |
Formular | The form as HTML element used for the opt-in. |
Opt-In Mail | The content of the opt-in mail as HTML. |
All data is stored for the duration you set in order to be able to prove that a visitor has registered via the double opt-in and that this has been confirmed. Even after an opt-out, the data will be kept for 30 days.
Export Double-Opt-in Data #
All performed opt-ins can be exported as a CSV file at any time. Both individual and all opt-ins can be exported. If categories are used, only opt-in information of a certain category can be exported as well.
Export all opt-in data
To export all data, go to Forge12 Double Opt-In > Dashboard in the WordPress backend. There you will find an overview of the most recent opt-ins. At the end of the table, you will find the button to export all entries as CSV.
Export individual opt-in data
It is also possible to export only single information. To do this, go to Forge12 Double Opt-In > Dashboard in the WordPress backend. Then move the mouse over the desired opt-in to get the link to the details page. On the details page, you will find the button to export the data (Export as CSV).
Export all opt-in data of a category
To export all opt-ins of a category, go to Forge12 Double Opt-In > Categories > [category name] in the WordPress backend. There you will find all opt-ins that have been assigned to the respective category. The option to export the opt-ins can be found at the end of the table (Export as CSV).
How to use the opt-out system #
With version 2 of the opt-in system, the possibility of giving visitors the option to unsubscribe from performed opt-ins was integrated.
The opt-out page for the visitor
First, you need a new page, on which everything else will be displayed for the visitor later. To do this, simply create a new page in the backend of WordPress and insert the following shortcode.
[f12-cf7-doubleoptin-optout-list]
Of course, you can continue to design the page and add additional content. The only important thing is that the shortcode is placed on the page.
Configure the opt-out
Next, go to Forge12 Double Opt-In > Opt-out in the backend of WordPress. There, you can now make all further settings for the opt-out.
Einstellung | Description |
Opt-Out Page | The page on which the [f12-cf7-doubleoptin-optout-list] shortcode is located must be specified here. The visitor will be redirected to this page once he performs the opt-out. |
Subject | The subject of the opt-out mail. |
Body | The message body of the opt-out mail. Here, the placeholder [doubleoptin_optout_url] must be explicitly integrated as a link. |
The opt-out form
The last thing to do is to integrate the opt-out form. For this, you use the following shortcode.
[f12-cf7-doubleoptin-optout-form]
The shortcode creates a simple form through which the visitor can access the opt-out process.
Once the form has been submitted, a one-time link is generated and sent to the selected e‑mail address. The link is only temporarily valid and will be deleted afterwards.
The shortcode for the form can be placed anywhere on the page. The display can then be done via the WordPress Customizer or by separate CSS files.
The Opt-Out List
As soon as the visitor clicks on the opt-out link, he will be redirected to the previously created page, where he will receive an overview of all performed and pending opt-ins. This can look like the following, for example:
The visitor then sees whether and when the opt-in was performed and how long the data is stored. Via Opt-Out now! He can also unsubscribe from performed opt-ins. The column “valid until” results from the configured settings.
Available filters and hooks for the extension #
For developers, we offer the possibility to access built-in WordPress hooks to connect the system to external interfaces.
Double opt-ins
Allows to process opt-ins that have been performed twice. (e.g. when the opt-in link is clicked twice).
/**
* @param string
* @param OptIn $OptIn
*/
function already_confirmed($hash, $OptIn){
// Do Something
}
add_action('f12_cf7_doubleoptin_already_confirmed', 'already_confirmed', 10, 2);
Before the opt-in confirmation
Allows to edit an opt-in before it is saved.
/**
* @param string
* @param OptIn $OptIn
*/
function before_confirm($hash, $OptIn){
// Do Something
}
add_action('f12_cf7_doubleoptin_before_confirm', 'before_confirm', 10, 2);
After the opt-in confirmation
Allows modifying the opt-in after confirmation. Also allows passing the opt-in to interfaces after confirmation.
/**
* @param string
* @param OptIn $OptIn
*/
function after_confirm($hash, $OptIn){
// Do Something
}
add_action('f12_cf7_doubleoptin_after_confirm', 'after_confirm', 10, 2);
After sending the opt-in mail
Allows to perform further steps after sending the opt-in mail.
/**
* @param array $form_data - An Array containing all dynamic form fields and placeholder data.
* @param int $post_id - The Form ID
*/
function after_optin_mail_sent($form_data, $post_id){
// Do Something
}
add_action('f12_cf7_doubleoptin_sent', 'after_optin_mail_sent', 10, 2);
Summary #
Using the Forge12 Double-Opt-in Plugin for Contact Form 7 is quick and easy thanks to its integration. Thanks to the logging of the data, proof of the double opt-in can be provided at any time.
Do you have ideas how to extend the plugin, or would you like to have additional features? Then just write us a comment.
Artikel von:
Marc Wagner
Hi Marc here. I’m the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.
Hi,
the Download csv doesn’t work. There is no button visible.
What can I do?
Kind regards
Hi Michael,
The CSV download feature is only available in the Pro version. If you already have the Pro version and still don’t see the CSV download button, please feel free to open a support ticket by writing us a mail.
Kind regards,
Marc