wpcf7_get_contact_form_by_old_id()CF7 1.0

Searches for a contact form by an old unit ID.

Хуков нет.

Возвращает

WPCF7_ContactForm. Contact form object.

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

wpcf7_get_contact_form_by_old_id( $old_id );
$old_id(int) (обязательный)
Old unit ID.

Код wpcf7_get_contact_form_by_old_id() CF7 5.6.3

function wpcf7_get_contact_form_by_old_id( $old_id ) {
	global $wpdb;

	$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
		. $wpdb->prepare( " AND meta_value = %d", $old_id );

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