Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 Bobz-zg/a80fe352f50225c844d1 to your computer and use it in GitHub Desktop.
Save Bobz-zg/a80fe352f50225c844d1 to your computer and use it in GitHub Desktop.
Populate ACF Select field choices with Gravity Forms
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