コード例 #1
0
ファイル: wp-mailjet.php プロジェクト: Anciela/anciela.info
function mailjet_subscribe_unsub_user_to_list($subscribe, $user_id)
{
    if (get_option('mailjet_password') && get_option('mailjet_username')) {
        $user = get_userdata($user_id);
        $MailjetApi = new Mailjet(get_option('mailjet_username'), get_option('mailjet_password'));
        if ($subscribe && ($list_id = get_option('mailjet_auto_subscribe_list_id'))) {
            $params = array('method' => 'POST', 'contact' => $user->data->user_email, 'id' => $list_id);
            $response = $MailjetApi->listsAddContact($params);
        } elseif (!$subscribe && ($list_id = get_option('mailjet_auto_subscribe_list_id'))) {
            $params = array('method' => 'POST', 'contact' => $user->data->user_email, 'id' => $list_id);
            $response = $MailjetApi->listsRemoveContact($params);
        }
    }
}