Multisite Auth MailChimp Addon lets you easily opt-in users from your WordPress network registration forms.
This plugin uses MailChimp API lib by @drewm to make API calls with MailChimp servers.
This plugin requires the parent plugin Multisite Auth
add_action('muauth_mc_catch_optin_response', function($response, $user_email, $lists){
// loop through lists
foreach ( $lists as $list_id ) {
$res = $response[$list_id];
if ( muauth_mc_status_success( $res['succes'] ) ) {
// this email ($user_email) was successfully opted-in, do actions
} else {
// error occured, could not opt-in, debug $res
}
}
}, 10, 3);
By default, the only information inserted to the mailing list is the email address. But there is a method to edit the list signup to add more information:
$MailChimp = muauth_mc();
$list_id = 'b1234346';
$subscriber_hash = $MailChimp->subscriberHash('davy@example.com');
$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => ['FNAME'=>'Davy', 'LNAME'=>'Jones'],
'interests' => ['2s3a384h' => true],
]);
print_r($result);