Last active
November 7, 2015 07:40
-
-
Save Bobz-zg/a80fe352f50225c844d1 to your computer and use it in GitHub Desktop.
Populate ACF Select field choices with Gravity Forms
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
function vb_acf_load_gforms( $field ) { | |
global $wpdb; | |
$sql = "SELECT * FROM {$wpdb->prefix}rg_form"; | |
$forms = $wpdb->get_results( $sql ); | |
$field['choices'] = array(); | |
if( $forms ) : | |
// load repeater from the options page | |
foreach ( $forms as $k => $v ) { | |
$field['choices'][ $v->id ] = apply_filters('the_title', $v->title); | |
} | |
endif; | |
return $field; | |
} | |
add_filter('acf/load_field/name=gf_form_field_name', 'vb_acf_load_gforms'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment