Support

Account

Home Forums General Issues get_field_reference doesn't work with register_field_group Reply To: get_field_reference doesn't work with register_field_group

  • I solved my problem reading the code of acf_form. I got this code:

    $post_id = 1;
    
    if ( strpos( $post_id, 'user_' ) !== false ) {
    	$filter = array( 'ef_user' => str_replace( 'user_', '', $post_id ) );
    } elseif ( strpos( $post_id, 'taxonomy_' ) !== false ) {
    	$filter = array( 'ef_taxonomy' => str_replace( 'taxonomy_', '', $post_id ) );
    } else {
    	$filter = array( 'post_id' => $post_id );
    }
    
    $field_groups = apply_filters( 'acf/location/match_field_groups', array(), $filter );
    $acfs = apply_filters( 'acf/get_field_groups', array() );
    
    if ( is_array( $acfs ) && is_array( $field_groups ) ) {
    	foreach( $acfs as $acf ) {
    		if ( in_array( $acf['id'], $field_groups ) ) {
    			$fields = apply_filters( 'acf/field_group/get_fields', array(), $acf['id'] );
    		}
    	}
    }