Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);
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