After many months of hard work version 1.1.0 of our ACF Custom Database Tables plugin is finally done. This release introduces support for the ACF Repeater Field type along with a number of other improvements and filters which enable developers to implement finer control over their custom database table structures.
Some important things to note for this release
This release ships with an upgrade to the generated JSON and PHP files used to route data in/out of custom database tables. This is triggered automatically, runs in the background, and should only take a second — you’ll see an admin notice indicating that it is either running or done. If, for some reason, this isn’t triggered or you have issues with fields not mapping correctly, you can run it manually at any time from the tools panel.
We already have a decent number of people running this plugin on their sites but as usual, play it safe and make sure you back up your sites and test in staging before deploying to your live websites.
You can now store ACF Repeater Fields in normalised table structures
Not only can you store repeater field data in custom database tables, but you can also opt to normalise their data in custom tables that are structured to match the repeater field. This makes repeater data incredibly flexible for custom SQL queries and opens up new possibilities for using repeater fields in complex builds.
You need to enable repeater field support either via a PHP filter (recommended) or via the plugin settings panel:
Once support is enabled, repeater fields will be included in table the generated table configuration files when saving a field group. By default, repeater field data is stored as an encoded JSON string in a single column. Consider the following repeater:
On post save, the data is stored in the custom table as follows:
If you wish to store an ACF repeater field’s values in a normalised database table of its own, you simply need to configure it to do so by adding a code snippet to either your functions.php file or your own configuration plugin (recommended). With the snippet in place, you can save the field group again and run through the table update process to create the new table. From this point, your repeater field data will be stored in something along the lines of the following:
Regardless of how you choose to store your ACF repeater field data, the template functions you are used to using —
get_sub_field() etc — all continue to work as normal so you don’t need to change the way you author your WordPress theme templates.
Plugin settings are manageable from the WordPress admin
You can now have a control panel set up within the plugin’s administrative screen which provides an easy overview and access to the plugin’s global settings:
The admin controls make it easier for people to experiment with different settings during development but it’s still recommended to use PHP filters to control the global settings where possible as this safeguards against accidental config changes whilst also making your configuration version controllable. When a setting is configured via PHP, the settings panel will show the setting as read-only and will prevent changes from being made:
You can now control table column data types
Custom database table columns default to the
LONGTEXT format as this is what the core meta tables use and ensures maximum compatibility. As of this release, you can now configure more precise data types which will make your database queries more efficient and make working with your data even more flexible.
The filters are used to generate the correct table schema and are executed when a field group is updated. The data type is stored in the generated JSON files and applied to the database when running the table update process. Learn more about controlling data types in the plugin documentation.
There’s plenty more in this release. We’ve added some fixes, enhancements, and more filters to provide developers with greater control. For a more comprehensive read, see what has changed in version 1.1 in the plugin documentation.
Development of version 1.2.0 has already begun with the main focus being on a data migration tool. Having a migration tool for moving data back and forth between custom tables and core meta tables will make the process of adding this plugin to an existing build that little be smoother.
You can expect to see some smaller enhancements ship over the coming weeks as well while we further improve on the codebase to prepare for more tooling and also release some small enhancements such as making those repeater row ID’s persist when storing repeater data in normalised tables.
When will the next release ship?
Whilst there was a lot of work that need to go into this release, the amount of work didn’t keep me busy this whole time and I’m very cognisant of how long this release has taken me to ship. Getting time on the plugin has been a challenge with my personal life and other work commitments usually dictating where my time goes. Over the last few months, I’ve taken steps to reduce my other commitments and with the recent sale of the WP Landing Kit plugin I now have more time to devote to furthering Hookturn and the ACF Custom Database Tables plugin.
You can expect to see new release every few months with a series of new planned features landing in 2021 that will make working with custom database tables easier and make your sites much more performant and scalable.