Quick plugin to sync new cart66 subscriptions to MailPress users

I’m working on a subscription site in WordPress for a client, and they are using cart66 as the shopping cart, and MailPress as the mailing list software. I needed a way to automatically sign up new Cart66 accounts to the Mailpress users. This tiny plugin does just that:

[php]
<?php
/*
Plugin Name: Cart66 MailPress Sync
Plugin URI: http://ponderwell.net/
Description: Creates mailpress account for cart66 accounts
Version: 1.0
Author: Michael Tracey
Author URI: http://ponderwell.net
License: GPL
*/
add_action( ‘cart66_after_order_saved’, ‘cart66ToMailpress’ );

function cart66ToMailpress($orderInfo) {
$order = new Cart66Order($orderInfo[‘id’]);
if($order->account_id > 0) {
$account = new Cart66Account($order->account_id);
if (class_exists(‘MP_User’)){
sync_mp_user($account->email, $account->first_name ." ". $account->last_name, ‘active’);
}
else {
echo "<!– MailPress is not available! –>";
}
}
}
function sync_mp_user($email, $name, $status = ‘active’){
$xl = strlen($email);
$xl = ((25 – $xl) < 0) ? 0 : 25 – $xl;
$x = $email . str_repeat( ‘ ‘, $xl);
if ( !is_email($email)) {
return false;
}

if ( ‘deleted’ != MP_User::get_status_by_email($email) ){

}
else{
MP_User::insert($email, $name, array(‘status’ => $status, ‘stopPropagation’ => true));
}
return MP_User::get_id_by_email($email);
}
[/php]

Just put this in your plugins directory, name it something like ‘cart66account2mailpress.php’ and then activate it. New accounts get signed up to the mailing list (at least for me!).

This scratched my itch on a site that I was working on, hope it works for you too. No warranty or guarantees, etc…