Skip to content

Instantly share code, notes, and snippets.

@danielpost
Last active May 21, 2019 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpost/7ee3f1eb48a7c2f9aad9aab599a2c519 to your computer and use it in GitHub Desktop.
Save danielpost/7ee3f1eb48a7c2f9aad9aab599a2c519 to your computer and use it in GitHub Desktop.
WordPress Form Plugins: Get list of all available forms
<?php
$forms = get_posts(['post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1]);
if (empty($forms)) {
return [];
}
return array_combine(wp_list_pluck($forms, 'ID'), wp_list_pluck($forms, 'post_title'));
<?php
if (!class_exists('GFAPI')) {
return [];
}
$forms = GFAPI::get_forms();
if (empty($forms)) {
return [];
}
return array_combine(wp_list_pluck($forms, 'id'), wp_list_pluck($forms, 'title'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment