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 5.9.8

function wpcf7_get_contact_form_by_hash( $hash ) {
	global $wpdb;

	$hash = trim( $hash );

	if ( strlen( $hash ) < 7 ) {
		return null;
	}

	$like = $wpdb->esc_like( $hash ) . '%';

	$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_hash'"
		. $wpdb->prepare( " AND meta_value LIKE %s", $like );

	if ( $post_id = $wpdb->get_var( $q ) ) {
		return wpcf7_contact_form( $post_id );
	}
}