wpcf7_get_contact_form_by_hash()CF7 1.0

Searches for a contact form by a hash string.

Хуков нет.

Возвращает

WPCF7_ContactForm. Contact form object.

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

wpcf7_get_contact_form_by_hash( $hash );
$hash(строка) (обязательный)
Part of a hash string.

Код wpcf7_get_contact_form_by_hash() CF7 6.1.6

function wpcf7_get_contact_form_by_hash( $hash ) {
	if ( ! preg_match( '/^[0-9a-f]{7,}$/', $hash ) ) {
		return null;
	}

	$contact_forms = WPCF7_ContactForm::find( array(
		'meta_query' => array(
			array(
				'key' => '_hash',
				'compare' => 'REGEXP',
				'value' => '^' . $hash,
			),
		),
		'posts_per_page' => 1,
	) );

	if ( $contact_forms ) {
		return wpcf7_contact_form( $contact_forms[0] );
	}
}