Support

Account

Home Forums ACF PRO Add field programmatically to group Reply To: Add field programmatically to group

  • Hi @timm

    The problem is that you said you want your users to be able to adjust the field groups. Please keep in mind that it’s not possible to modify the fields registered via PHP code from the backend.

    Also, please bear in mind that you can’t mix between the fields created from the backend and the one created via PHP code. This means that you can only add fields using PHP code to the flexible content you’ve created via PHP code too.

    If that’s what you are after, then you should be able to add a new field to a flexible content layout like this:

    acf_add_local_field(array(
        "key" => 'field_key',
        "label" => 'field label',
        'name' => 'field_name',
        'type' => 'text',
        'parent' => 'field_1234567890abc',
        'parent_layout' => 'abcdefghijklm',
    ));

    Where “field_1234567890abc” is the flexible content key and “abcdefghijklm” is the layout key.

    I hope this makes sense 🙂