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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.