Support

Account

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.