wpcf7_get_contact_form_by_old_id()
Searches for a contact form by an old unit ID.
Хуков нет.
Возвращает
WPCF7_ContactForm|null. Contact form object, or null if not found.
Использование
wpcf7_get_contact_form_by_old_id( $old_id ): ?WPCF7_ContactForm;
- $old_id(int) (обязательный)
- Old unit ID.
Код wpcf7_get_contact_form_by_old_id() wpcf7 get contact form by old id CF7 6.2.4.1
function wpcf7_get_contact_form_by_old_id( $old_id ): ?WPCF7_ContactForm {
$contact_forms = WPCF7_ContactForm::find( array(
'meta_query' => array(
array(
'key' => '_old_cf7_unit_id',
'type' => 'DECIMAL',
'value' => $old_id,
),
),
'posts_per_page' => 1,
) );
if ( empty( $contact_forms ) ) {
return null;
}
return wpcf7_contact_form( $contact_forms[0] );
}