Last active
August 5, 2018 17:28
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! Saved me some time 👌