Skip to content

Commit

Permalink
#69 MailChimp subscription VBOs
Browse files Browse the repository at this point in the history
  • Loading branch information
BBGuy committed Dec 15, 2015
1 parent 2e5f8b7 commit f231a57
Showing 1 changed file with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,54 @@ function kendra_home_mods_menu() {
return $items;
}

/**
* Implements hook_action_info().
*/
function kendra_home_mods_action_info() {

return array(
'kendra_home_mods_subscribe_mailchimp' => array(
'label' => t('Subscribe to mailchimp'),
'type' => 'user',
'configurable' => FALSE,
'triggers' => array('any'),
),
'kendra_home_mods_unsubscribe_mailchimp_action' => array(
'label' => t('Unsubscribe from mailchimp'),
'type' => 'user',
'configurable' => FALSE,
'triggers' => array('any'),
),
'kendra_home_mods_resubscribe_mailchimp_action' => array(
'label' => t('Resubscribe to mailchimp'),
'type' => 'user',
'configurable' => FALSE,
'triggers' => array('any'),
),
);
}

/**
* Action function.
*/
function kendra_home_mods_subscribe_mailchimp(&$user, $context = array()) {
$uid = $user->uid;
kendra_home_mods_mailchimp_subscribe($uid);
}


function kendra_home_mods_unsubscribe_mailchimp_action(&$user, $context = array()) {
$uid = $user->uid;
kendra_home_mods_mailchimp_unsubscribe($uid);
}

function kendra_home_mods_resubscribe_mailchimp_action(&$user, $context = array()) {
$uid = $user->uid;
kendra_home_mods_mailchimp_unsubscribe($uid);
kendra_home_mods_mailchimp_subscribe($uid);
}


/**
* Test mailchimp function for subscribe using a url call
*/
Expand Down Expand Up @@ -352,7 +400,7 @@ function kendra_home_mods_mailchimp_subscribe($uid) {
* The $list_id is available from the mailchimp:
* list->Settings->List name and Campaign defaults
*/
function kendra_home_mods_mailchimp_unsubscribe($list_id, $uid) {
function kendra_home_mods_mailchimp_unsubscribe($uid) {
$target_user = user_load($uid);
// Using the field.
$target_user->field_mc_subscribe['und'][0] = array('subscribe' => 0);
Expand Down

0 comments on commit f231a57

Please sign in to comment.