Home › Forums › ACF PRO › Auto import json export file › Reply To: Auto import json export file
Hey,
Just noticed this thread and don’t know whether what I have achieved is the same functionality you are searching for.
For the move to production, I renamed the “acf-json” folder to “fields” and had the following code run on init.
$dir = new DirectoryIterator( get_template_directory() . '/fields/' );
foreach( $dir as $file )
{
// var_dump( $file );
if ( !$file->isDot() && 'json' == $file->getExtension() )
{
$array = json_decode( file_get_contents( $file->getPathname() ), true );
register_field_group( $array );
}
}
It doesn’t import the fields, but still registers them. The benefit of doing it this way is the client can’t go in a modify fields from the backend.
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.