WPCF7_ConstantContact_ContactPostRequest::build()publicCF7 1.0

Метод класса: WPCF7_ConstantContact_ContactPostRequest{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WPCF7_ConstantContact_ContactPostRequest = new WPCF7_ConstantContact_ContactPostRequest();
$WPCF7_ConstantContact_ContactPostRequest->build( $submission );
$submission(WPCF7_Submission) (обязательный)
-

Код WPCF7_ConstantContact_ContactPostRequest::build() CF7 5.6.4

public function build( WPCF7_Submission $submission ) {
	$this->set_create_source( 'Contact' );

	$this->set_first_name(
		$submission->get_posted_string( 'your-first-name' )
	);

	$this->set_last_name(
		$submission->get_posted_string( 'your-last-name' )
	);

	if ( ! ( $this->first_name || $this->last_name )
	and $your_name = $submission->get_posted_string( 'your-name' ) ) {
		$your_name = preg_split( '/[\s]+/', $your_name, 2 );
		$this->set_first_name( array_shift( $your_name ) );
		$this->set_last_name( array_shift( $your_name ) );
	}

	$this->set_email_address(
		$submission->get_posted_string( 'your-email' ),
		'implicit'
	);

	$this->set_job_title(
		$submission->get_posted_string( 'your-job-title' )
	);

	$this->set_company_name(
		$submission->get_posted_string( 'your-company-name' )
	);

	$this->set_birthday(
		$submission->get_posted_string( 'your-birthday-month' ),
		$submission->get_posted_string( 'your-birthday-day' )
	);

	if ( ! ( $this->birthday_month && $this->birthday_day ) ) {
		$date = $submission->get_posted_string( 'your-birthday' );

		if ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})$/', $date, $matches ) ) {
			$this->set_birthday( $matches[2], $matches[3] );
		}
	}

	$this->set_anniversary(
		$submission->get_posted_string( 'your-anniversary' )
	);

	$this->add_phone_number(
		$submission->get_posted_string( 'your-phone-number' )
	);

	$this->add_street_address(
		$submission->get_posted_string( 'your-address-street' ),
		$submission->get_posted_string( 'your-address-city' ),
		$submission->get_posted_string( 'your-address-state' ),
		$submission->get_posted_string( 'your-address-postal-code' ),
		$submission->get_posted_string( 'your-address-country' )
	);

	$service_option = (array) WPCF7::get_option( 'constant_contact' );

	$contact_lists = isset( $service_option['contact_lists'] )
		? $service_option['contact_lists'] : array();

	$contact_form = $submission->get_contact_form();

	$prop = $contact_form->prop( 'constant_contact' );

	if ( ! empty( $prop['enable_contact_list'] )
	and ! empty( $prop['contact_lists'] ) ) {
		foreach ( (array) $prop['contact_lists'] as $list_id ) {
			$this->add_list_membership( $list_id );
		}
	}
}