Created
September 15, 2015 07:59
-
-
Save ravinderk/f1d01fd4e65d52ab755b to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Add gravity forms to acf gravityform select field | |
* | |
* @param array $field field data. | |
* | |
* @return mixed | |
*/ | |
function acf_load_color_field_choices( $field ) { | |
// Reset choices. | |
$field['choices'] = array(); | |
// Add gravity form to choices. | |
if ( class_exists( 'RGFormsModel' ) ) { | |
$forms = RGFormsModel::get_forms( null, 'title' ); | |
foreach ( $forms as $index => $form ) { | |
if( ! $index ){ | |
$field['choices'][ 'none' ] = 'None'; | |
} | |
$field['choices'][ $form->id ] = $form->title; | |
} | |
} | |
// Return the field. | |
return $field; | |
} | |
add_filter( 'acf/load_field/name=gravity_form', 'acf_load_color_field_choices' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment