wpcf7_get_contact_form_by_hash()
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() 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 ); } }