Exemplo n.º 1
0
 public function addtomailjet($email, $idlist)
 {
     $mj = new Mailjet();
     $params = array('method' => 'POST', 'contact' => $email, 'id' => $idlist);
     $response = $mj->listsAddContact($params);
     return $contact_id = $response->contact_id;
 }
            case 'London':
                $id = '1044322';
                break;
            case 'North England':
                $id = '1044323';
                break;
            case 'East England':
                $id = '1044325';
                break;
            case 'Midlands':
                $id = '1044326';
                break;
            case 'Scotland':
                $id = '1044379';
                break;
            case 'International / Global':
                $id = '1044328';
                break;
        }
    }
} */
// Include Mailjet's API Class
include_once 'mailjet-api-class.php';
// Create a new Object
$mj = new Mailjet();
# Parameters
$params = array('method' => 'POST', 'contact' => $email, 'id' => $id);
# Call
$response = $mj->listsAddContact($params);
# Result
$contact_id = $response->contact_id;
Exemplo n.º 3
0
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);
        }
    }
}