The first function is a generic function to make any type of request to the MailChimp API v3.

The second function is used to specifically create a MailChimp campaign with the MailChimp API version 3. You would use it like this to create a campaign:

$campaign_id = isa_create_mailchimp_campaign( $list_id, $subject );

The $list_id would be your MailChimp List ID that you want to send this campaign to. The $subject is the email subject line for this campaign. This function, isa_create_mailchimp_campaign, will return the campaign ID if it was successfully created, otherwise it will return false. (See the Usage Example below.)

Then, you would use the campaign ID to assign a template and set the HTML content for this campaign. That’s what the third function is for (isa_set_mail_campaign_content).

These first 3 functions simply go into your functions file. These 3 functions simply provide an API to be able to create, edit, and send MailChimp campaigns through WordPress, using the MailChimp API v3. After adding these functions, see the Usage Example, below.

Usage Example: Create a MailChimp Campaign, Set The Content, and Send The Campaign

This example will show you how to use the 3 functions (from above) to create a MailChimp campaign, and then set the content for that campaign, and then send the campaign. Note that this will send the campaign, immediately. (If you don’t want to send the campaign, comment out lines 37–51.)

The lines to edit in this section are:

line 7: Replace $list_id with your own MailChimp List ID to send this campaign to. (I recommend that, for testing purposes, you first use a List ID that has only your own test email address in it, so that you can test this and the email campaign will only be sent to you.)

line 7: Replace $subject with the email subject line for this campaign.

line 18: Replace 99999 with your own Template ID that you are going to use for this campaign. This should be a “Code your own” template that you created in MailChimp. A “Code your own” template will have the “mc:edit area” which is required so that you can set the content through the MailChimp API.

line 24: Replace std_content00 with the unique mc:edit area name for the body content area of your template.

line 24: Replace “THIS IS THE CONTENT OF MY EMAIL MESSAGE.” with your desired content for the body of the email message. This can include HTML.