wpcf7_save_contact_form()CF7 1.0

Saves the contact form data.

Хуки из функции

Возвращает

null. Ничего (null).

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

wpcf7_save_contact_form( $data, $context );
$data
.
По умолчанию: ''
$context
.
По умолчанию: 'save'

Код wpcf7_save_contact_form() CF7 6.1.6

function wpcf7_save_contact_form( $data = '', $context = 'save' ) {
	$data = wp_parse_args( $data, array(
		'id' => -1,
		'title' => null,
		'locale' => null,
		'form' => null,
		'mail' => null,
		'mail_2' => null,
		'messages' => null,
		'additional_settings' => null,
	) );

	$data['id'] = (int) $data['id'];

	if ( -1 === $data['id'] ) {
		$contact_form = WPCF7_ContactForm::get_template();
	} else {
		$contact_form = wpcf7_contact_form( $data['id'] );
	}

	if ( empty( $contact_form ) ) {
		return false;
	}

	if ( null !== $data['title'] ) {
		$contact_form->set_title( $data['title'] );
	}

	if ( null !== $data['locale'] ) {
		$contact_form->set_locale( $data['locale'] );
	}

	$properties = array();

	if ( null !== $data['form'] ) {
		$properties['form'] = wpcf7_sanitize_form( $data['form'] );
	}

	if ( null !== $data['mail'] ) {
		$properties['mail'] = wpcf7_sanitize_mail( $data['mail'] );
		$properties['mail']['active'] = true;
	}

	if ( null !== $data['mail_2'] ) {
		$properties['mail_2'] = wpcf7_sanitize_mail( $data['mail_2'] );
	}

	if ( null !== $data['messages'] ) {
		$properties['messages'] = wpcf7_sanitize_messages( $data['messages'] );
	}

	if ( null !== $data['additional_settings'] ) {
		$properties['additional_settings'] = wpcf7_sanitize_additional_settings(
			$data['additional_settings']
		);
	}

	$contact_form->set_properties( $properties );

	do_action( 'wpcf7_save_contact_form', $contact_form, $data, $context );

	if ( 'save' === $context ) {
		$contact_form->save();
	}

	return $contact_form;
}