Custom Meta

ACF Extended allows developers to add custom metas values in the Field Group settings directly from the Field Group administration.

Set Settings in PHP

It is possible to set this setting in PHP using the acf/load_field_group hook. Note that this hook is used everywhere, including in ACF admin and tools screen. Which means the setting will be used when exporting the field group.

To avoid that behavior, you can use the acfe_is_admin_screen() function as condition. Usage example:

add_filter('acf/load_field_group', 'my_acf_field_group');
function my_acf_field_group($field_group){
    
    // Bail early if in ACF admin/tool screen
    if(acfe_is_admin_screen())
        return $field_group;
    
    // Target a specific key
    if($field_group['key'] !== 'group_5f20935b9a777')
        return $field_group;
    
    // Settings
    $field_group['acfe_meta'][] = array(
        'acfe_meta_key' => 'foo',
        'acfe_meta_value' => 'bar'
    );
    
    // Return
    return $field_group;
    
}

Retrieve Settings

Custom meta values are saved in the Field Group array, under acfe_meta key. It can be retrieved using acf_get_field_group(). Usage example:

$field_group = acf_get_field_group('group_5f20935b9a777');

/*
 * [instruction_placement] => label
 * [hide_on_screen] =>
 * ...
 * [acfe_meta] => Array
 * (
 *      [5f3a7307cc3ba] => Array
 *      (
 *          [acfe_meta_key] => foo
 *          [acfe_meta_value] => bar
 *      )
 * 
 *      [5f3a730dcc3bb] => Array
 *      (
 *          [acfe_meta_key] => key
 *          [acfe_meta_value] => value
 *      )
 * )
 * ...
 */

You can then loop thru values using foreach(). Usage example:

// Get field group
$field_group = acf_get_field_group('group_5f20935b9a777');

// Get field group meta
$field_group_meta = acf_array($field_group['acfe_meta']);

// Loop
foreach($field_group_meta as $row){
    
    $key = $row['acfe_meta_key'];
    $value = $row['acfe_meta_value'];
    
    // Do something...
    
}