Mailchimp Approval List Subscribe System

mailchimp-logo[1]Recently I helped a client setup a Mailchimp List , the users could sign up on the website however the client wanted to verify the users before they got added to the list with a file attachment upload so competitors didn’t subscribe to the list!

Unfortunately MailChimp doesn’t have this functionality , so I had to build something that would do this.

I created a seperate signup form via a separate form that would email the Approver , I used/purchased this form as it made upload attachments easy as well as HTML email headers. The email had the First Name , Last Name , Email and attachment.

The email also had an HTML approval link at the bottom , which was a link that passed the following details to a php file list,fname,lname, email below in the form test.php?list=1&fname=john&lname=smith&[email protected]

This then added the user to the list via the MailChimp API on clicking or displayed an error if the user was already signed up!

Once approved , the user gets emailed asking them to accept the subscription !

<?php
$api_key = "mailchimapikeyGetFromControlPanel";
 
switch ($_GET["list"]) {
    case "1":
$name = "List1";
$list_id = "getlistidfrommailchimpcontrol";
        break;
    case "2":
$name = "List2";
$list_id = "getlistidfrommailchimpcontrol";
        break;
}
 
 $merge_vars = Array( 
        'EMAIL' => $_GET['email'],
        'FNAME' => $_GET['fname'], 
        'LNAME' => $_GET['lname']
    );
 
//You need to download mailchimp API from here https://github.com/zf-fr/zfr-mailchimp
require('src/Mailchimp.php');
$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
$subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => $_GET["email"]), $merge_vars );  
 
if ( ! empty( $subscriber['leid'] ) ) {
echo $_GET["email"]." Subscribed to ".$name;
}
else
{
echo "failed";
}
 
?>

 

*********************** Update***********************

Just asked if this can be used via Squarespace

Squarespace cannot host PHP Files ….

You use .js files ( instead of PHP ) in Squarespace to call the mailchimp API e.g.
 
 
Js files you will need to play with to get this to work : https://github.com/gomfunkel/node-mailchimp
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 10.00 out of 5)
Loading...