Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

MP_Addon_ConstantContact::export_contacts( array $leads )

Export leads activity to Constant Contact.


Parameters Parameters

$leads

(array) (Required) leads ids


Top ↑

Source Source

File: calculator-constant-contact-add-on/inc/MP_Addon_ConstantContact.php

	private function export_contacts($leads){

		$list_id = get_option(MortgagePlatform::$prefix . 'constant_contact')['constant_contact_lists'] ?? 'default';

		if('default' === $list_id){
			return;
		}

		$leads_data = array();
		foreach ($leads as $lead) {
			$leads_data[] = array(
				'first_name' => get_post_meta( $lead, MortgagePlatform::$prefix . 'lead_firstname', true ),
				'last_name'  => get_post_meta( $lead, MortgagePlatform::$prefix . 'lead_secondname', true ),
				'email'      => get_post_meta( $lead, MortgagePlatform::$prefix . 'lead_email', true ),
				'phone'      => get_post_meta( $lead, MortgagePlatform::$prefix . 'lead_phone', true ),
			);
		}

		$data = array(
			"import_data" => $leads_data,
			"list_ids" => array($list_id)
		);

		$url = "https://api.cc.email/v3/activities/contacts_json_import";

		$header = array(
			"Authorization" => 'Bearer ' . $this->get_constant_contact_access_token()['access_token'] ?? '',
			'content-type'  => 'application/json'
		);

		$response = wp_remote_post( $url, array(
				'headers' => $header,
				'body'    => json_encode( $data )
			)
		);

		$token_request_data = json_decode( $response['body'], true );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.