/** * Unsubscribe process */ function unsubscribe() { $mailin = new Mailin('https://api.sendinblue.com/v1.0', SIB_Manager::$access_key, SIB_Manager::$secret_key); $code = esc_attr($_GET['code']); $list_id = intval($_GET['li']); $contact_info = SIB_Model_Contact::get_data_by_code($code); if ($contact_info != false) { $email = $contact_info['email']; $response = $mailin->get_user($email); if ($response['code'] == 'success') { $attributes = $response['data']['attributes']; $listid = $response['data']['listid']; $blacklisted = $response['data']['blacklisted']; $listid = array_diff($listid, array($list_id)); if (count($listid) == 0) { $mailin->delete_user($email); SIB_Model_Contact::remove_record($contact_info['id']); } else { $mailin->create_update_user($email, $attributes, $blacklisted, $listid, null); } } } ?> <body style="margin:0; padding:0;"> <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%"> <tbody> <tr style="border-collapse:collapse;"> <td style="border-collapse:collapse;" align="center"> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;"> <?php _e('Unsubscribe', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td align="left"> <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;"> <br> <?php _e('Your request has been taken into account.', 'sib_lang'); ?> <br> <br> <?php _e('The user has been unsubscribed', 'sib_lang'); ?> <br> <br> -SendinBlue</div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> <?php exit; }
/** * Unsubscribe process */ function unsubscribe() { $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key); $code = esc_attr($_GET['code']); $list_id = intval($_GET['li']); $contact_info = SIB_Model_Contact::get_data_by_code($code); if ($contact_info != false) { $email = $contact_info['email']; $data = array('email' => $email); $response = $mailin->get_user($data); if ($response['code'] == 'success') { $info = $response['data']['attributes']; $blacklisted = 1; $blacklisted_sms = isset($attributes['SMS']) ? 1 : 0; SIB_Model_Contact::remove_record($contact_info['id']); $data = array(); $attribute_key = implode('|', array_keys($info)); $attribute_val = implode('|', array_values($info)); $ip = $this->get_the_user_ip(); $data['attributes_name'] = $attribute_key; $data['attributes_value'] = $attribute_val; $data['category'] = ''; $data['email'] = $email; $data['listid'] = $list_id; $data['blacklisted'] = $blacklisted; $data['blacklisted_sms'] = $blacklisted_sms; $data['source'] = 'Wordpress'; $data['ip'] = $ip; $response = $mailin->updateUser($data); } } ?> <body style="margin:0; padding:0;"> <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%"> <tbody> <tr style="border-collapse:collapse;"> <td style="border-collapse:collapse;" align="center"> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;"> <?php _e('Unsubscribe', 'sib_lang'); ?> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"></td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td align="left"> <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;"> <br> <?php _e('Your request has been taken into account.', 'sib_lang'); ?> <br> <br> <?php _e('The user has been unsubscribed', 'sib_lang'); ?> <br> <br> -SendinBlue</div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" width="540"> <tbody> <tr> <td style="line-height:0; font-size:0;" height="20"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> <?php exit; }