Home › Forums › Feature Requests › Import PHP for further use in UI tool › Reply To: Import PHP for further use in UI tool
There is nothing built into ACF that will let you import php code. You need to manually get the field group, convert it to JSON and then save it to a file.
// create field group in php
$group = acf_get_field_group('group_key');
$group['fields'] = acf_get_fields('group_key');
$json = json_encode($group);
// save the json to a file http://php.net/manual/en/function.file-put-contents.php
// there are other ways to do this as well
When I’m converting a field group to PHP I generally also export a JSON version so that if I need to I can import it to make changes.
The only reason I use PHP is if I want to make everything available for translation or I am going to do things that the ACF UI is incapable of doing, like building a dynamic field group that changes based on the page that’s being edited. If I am not worried about any of these conditions then I export the group as JSON and I add a load point to make ACF load the JSON files.
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.