Add customer to MailChimp

This How-To shows the use of MailChimp's API to subscribe an ABPro booking customer to your MailChimp List.


  • I know nothing about using MailChimp so do not ask me about it.
  • MailChimp has a rich API with many capabilities, this How-To only does one thing - it makes a subscribe call passing the customer's email.
  • MailChimp has many settings to control how your list works, subscribe confirmations, etc. For this How-To I created a Free account and one list. All other settings are default.
  • It is assumed you already have a MailChimp account, if not see


Steps involved:

  1. Download API, unzip and upload to your Joomla/ABPro site.
  2. Edit the API config file to set your API Key and List ID.
  3. Edit ABPro file to add call to mailchimp.



ABPro 3.0.5 will have MailChimp integration built in ;-)



Step 1.

The MailChimp PHP API can be downloaded here..


The zip file contains an 'examples' folder, and in that an 'inc' folder.



Extract the 'inc' folder and upload it to the main directory of your Joomla site.




Step 2.

In the inc folder you will see a config file called

Edit that file:



To get an API key see, your 'account settings', 'extras', 'API Keys'.




To get a List ID see, Lists, select the list you want ABPro to add people to, select 'Settings', 'List names and defaults'.



Step 3

Where/when, in the ABPro workflow, you want to insert the new name is up to you.
Here I will insert during the processing of a new booking in the GAD booking screen controller, after the booking is inserted in the database but before the customer is ether sent to PayPal or email confirmations are sent. It seems like a good place.

File: \components\com_rsappt_pro3\controllers\booking_screen_gad.php

Around line 354 look for:

// if "accepted", add to calendar
    if($request_status == "accepted"){
        addToCalendar($last_id->last_id, $apptpro_config);

    if(($paypal_submit == "1" || $paypal_submit == "2" || $paypal_submit == "3") && floatval($grand_total) > 0){


Insert the red code:

// if "accepted", add to calendar
    if($request_status == "accepted"){
        addToCalendar($last_id->last_id, $apptpro_config);

This Example shows how to Subscribe a New Member to a List using the MCAPI.php
class and do some basic error checking.

Based on the MailChimp sample code, modified to log to ABPro Errorlog

require_once JPATH_ROOT.'/inc/MCAPI.class.php';
require_once JPATH_ROOT.'/inc/'; //contains apikey

$api = new MCAPI($apikey);

$merge_vars = array('LNAME'=>$name, 
    // 'GROUPINGS'=>array(
    // array('name'=>'Your Interests:', 'groups'=>'Bananas,Apples'),
    // array('id'=>22, 'groups'=>'Trains'),
    // )

// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!
$retval = $api->listSubscribe( $listId, $email, $merge_vars );

if ($api->errorCode){
    logIt("Error on MailChimp Subscribe attempt: Code=".$api->errorCode.", Msg=".$api->errorMessage);
} else {
    logIt("MailChimp Subscribed - ".$email);

if(($paypal_submit == "1" || $paypal_submit == "2" || $paypal_submit == "3") && floatval($grand_total) > 0){



ABPro, like Joomla, just stores 'name' whereas MailChimp has 'firstname' and 'lastname'.

There is no perfect way to parse a name into first/last but if you wanted to add some code to try it, here is a thread that offers many options..




Information returned from MailChimp is added to the ABPro ErrorLog so look there first..