-
-
Save iMazed/4cf573e07577d9d5a486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Primux Mailchimp | |
Plugin URI: http://primux.dk/ | |
Description: Add new users to a Mailchimp list | |
Version: 1.0 | |
Author: Primux Media | |
Author URI: http://primux.dk/ | |
*/ | |
add_action( 'user_register', 'mux_mailchimp_add' ); | |
function mux_mailchimp_add( $user_id ) { | |
$user = get_user_by('id', $user_id); | |
$apikey = ''; // API Key | |
$listid = ''; // List ID | |
// $merges = array('FNAME'=>'Dave', 'LNAME'=>'Gilmour'); // IF you want to add other fields | |
$double_optin=false; | |
$update_existing=false; | |
$replace_interests=true; | |
$send_welcome=false; | |
$email_type = 'html'; | |
$data = array( | |
'email_address' => $user->user_email, | |
'apikey' => $apikey, | |
// 'merge_vars' => $merges, | |
'id' => $listid, | |
'double_optin' => $double_optin, | |
'update_existing' => $update_existing, | |
'replace_interests' => $replace_interests, | |
'send_welcome' => $send_welcome, | |
'email_type' => $email_type | |
); | |
$payload = json_encode($data); | |
//replace us2 with your actual datacenter | |
$submit_url = "http://us2.api.mailchimp.com/1.3/?method=listSubscribe"; | |
$feedback = wp_remote_post( $submit_url, array( 'body' => $payload ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment