Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active August 5, 2018 17:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuadavidnelson/0650acfcaa123720510e to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/0650acfcaa123720510e to your computer and use it in GitHub Desktop.
A function to return an array of gravity forms for a CMB2 select field.
<?php
/**
* Get an array of gravity forms.
*
* @since 1.0.0
*
* @return void
*/
function jdn_gf_options() {
$form_array = array();
// Gravity Form
if ( class_exists( 'RGFormsModel' ) ) {
$forms = RGFormsModel::get_forms( null, 'title' );
if( !empty( $forms ) && is_array( $forms ) ) {
foreach( $forms as $form ) {
if( isset( $form->title, $form->id ) )
$form_array[ $form->id ] = $form->title;
}
}
}
return $form_array;
}
@tnorthcutt
Copy link

Thanks for this! Saved me some time 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment