Disable Double Opt-in for Divi Email Optin Module

by | Jun 14, 2018 | Business | 0 comments

The development setup for all of the websites I run, including this site, a couple other blogs, and a few sites used for business purposes, consists of a WordPress installation running a highly-sophisticated theme called Divi. If you are reading this post, you are probably well familiar with Divi. For the most part, Divi is an exceptionally powerful tool for rapidly building beautifully-designed sites. That said, Divi is not without its little quirks here and there.

I’ve recently been building a landing page for a project I am currently working on called Plinthi. The site is designed to share information with visitors about an upcoming Kickstarter campaign and to collect emails from those who are interested in staying informed about Plinthi. To collect emails from visitors, I used Divi’s Email Opin Module. For managing the emails collected on the site, I used MailChimp.

There is nothing in particular wrong with this email optin functionality. The module does look great, and it was extremely easy to design and deploy. However, for this particular page, I wanted to disable double opt-in. This is where I ran into some difficulty.

What is Double Opt-In?

MailChimp offers two different mechanisms to add email address to your lists: single opt-in and double opt-in. Single opt-in is very simple. A user submits their email address via a form, like the one shown above, and it is immediately added to your email list.

Double opt-in is slightly more complicated. The process still starts with a visitor submitting their email address via a form on your site. Then, rather than being immediately added to your list, MailChimp will send a confirmation email to the email address entered. In order to be added to your list, the owner of that email address must accept the invitation in the double opt-in email.

This image is from the MailChimp documentation site.

Disable Double Opt-in for your Divi Email Optin Module

It turns out that disabling MailChimp double opt-in for your Divi Email Optin Module is quite easy, you just need to know where to look. To make the module use single opt-in, we will only need to change one line of code; actually we will only need to change one word.

Now you might think we could avoid any coding because MailChimp has an option for enabling or disabling double opt-in within the settings for your lists. However, this setting only controls the forms build within MailChimp. This setting has no effect on the behavior of the Divi Email Optin Module.

Before we begin, it should be noted that this method is a bit of a hack. I’ve spoken with Elegant Themes about disabling MailChimp double opt-in using native methods and they said they will update the theme with that functionality in the future. But until that update comes, follow the process below to force your Divi Email Optin Module to use single opt-in for your MailChimp lists. The other important note about this process is that it will make all of your Email Optin Modules use single opt-in. You will not be able to pick and choose the method used by individual forms.

Let’s get started.

Step 1: Create a Child Theme

Whenever you are making changes to your WordPress themes, it is always best to create a child theme to house your adjustments. There are two main reasons for this. First, using a child theme will offer safety. Just in case something goes wrong with the changes we are about to make, we can always revert to the original Divi theme. Second, using a child theme will help make certain the changes we will soon make will not revert the next time there is an update to Divi.

You can get a bunch of information about creating child themes in the WordPress Codex.

2. Download the MailChimp API File

Within the Divi theme, there is a file that allows your site to interact with MailChimp via the MailChimp API. We will be making a minor change to this file in order to force the Divi Email Optin Module to use single opt-in.

So, head over the cPanel for your site and choose File Manager. Navigate to the directory for your site. You will find the file controlling the API at the location below. It is buried fairly deep within Divi.

📂 wp-content > 📂 themes > 📂 Divi > 📂 core > 📂 components > 📂 api > 📂 email > 🗎 MailChimp.php

Download the MailChimp.php file and save it some place on your computer.

3. Recreate Directory Structure for your Child Theme

We need to recreate the directory structure we just followed to download the MailChimp.php file for your Divi child theme. So, back in cPanel’s file manager, navigate to

📂 wp-content > 📂 themes > 📂 Divi Child

Then, use the + Folder button in the upper-left corner of the screen to create the rest of the directory structure.

> 📂 core > 📂 components > 📂 api > 📂 email

4. Modify the API File

Alright, now we are finally at the part where we will actually enable single opt-in for the Divi Email Optin Module. Using your favorite text editor, open the MailChimp.php file you downloaded earlier.

Scroll all the way down to line 289. It looks like this:

$args['status'] = $dbl_optin ? 'pending' : 'subscribed';

Interestingly, despite the fact that Divi does not allow double opt-in to be disabled within Divi’s settings or within the Email Optin Module, there is actually a variable in the code for controlling this option. Anyway, in the ternary statement on line 289, there are two possible options for statusMailChimp API documentation that can be passed to the MailChimp API. The explains that a status of “pending” will trigger double opt-in, whereas a status of “subscribed” will use single opt-in.

So, therefore, to make the Divi Email Optin Module to use single opt-in, just change the ‘pending’ part of the ternary statement to ‘subscribed’. This way, the only option available to the Email Optin Module is to use single opt-in. The resulting code on line 289 will look like this:

$args['status'] = $dbl_optin ? 'subscribed' : 'subscribed';

5. Upload new MailChimp.php File

With the MailChimp API file updated to force the Email Optin Module to use single opt-in, we just need to upload the file into the child theme for the change to take effect. In cPanel’s File Manager, navigate into your child theme folder for the email API we created earlier. Click the Upload button from the top navigation and upload the modified MailChimp.php file.

Test your Email Optin Module

With the theme updated, you will want to give your Divi Email Optin Module a test before deploying it for public use. When you enter an email address into the form, and press the submit button, the email should be added to your list in MailChimp immediately.

Want to fix your Amazon Echo Dot?

Do you ever wonder why your Echo Dot does not have legs?

Plinthi is fixing this design oversight.

Sign up for HUGE discounts when we launch on Kickstarter! Sign up now and you could also win a Google Home or Amazon Echo.

Thanks! Your entry has been received.

Share This