From f231a57d573df2e09e7cc9f04323fa9db4e74a0d Mon Sep 17 00:00:00 2001 From: guy_schneerson Date: Tue, 15 Dec 2015 11:56:02 +0000 Subject: [PATCH] #69 MailChimp subscription VBOs --- .../kendra_home_mods/kendra_home_mods.module | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/sites/all/modules/custom/kendra_home_mods/kendra_home_mods.module b/sites/all/modules/custom/kendra_home_mods/kendra_home_mods.module index 7b8a2318..028b4965 100644 --- a/sites/all/modules/custom/kendra_home_mods/kendra_home_mods.module +++ b/sites/all/modules/custom/kendra_home_mods/kendra_home_mods.module @@ -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 */ @@ -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);