ACF Custom Database Tables v1.0

Heads up! You're browsing the documentation for an older version of the plugin. Consider checking out the current released version.

Creating your first table

Table creation/modification is a two part process:

  1. First, we need to generate (or update) the field group’s table definition JSON file.
  2. Then, we need to apply the definition to the database in order to create new tables or modify existing ones.

Generating the definition file

  1. Head to the field group you wish to create a table for.
  2. Make sure the field group has one object mapping in its location settings – Either User Form or Post Type will work
  3. Scroll down to the ACF Custom Database Table Settings meta box and toggle the Manage Table Definition option to Yes.
  4. Enter a table name for your table. You can only specify this once, so choose wisely. Changing this down the track is not impossible, but currently requires modification of post metadata for the field group and an SQL query to modify the database.
  5. In the Publish meta box, click Update.
  6. This will generate your table definition as a JSON file. Details of this will be output in the post updated message towards the top of the screen.

Applying the definition file to the database

  1. You can either click on the blue Manage Database Tables button in the post update message or you can head to Custom Fields > Database Tables > Manage Tables.
  2. Review the information on the screen and take a full backup of your database as per the instructions.
  3. When you are ready to apply the changes, click the confirmation check box and then click the blue Create/Update Tables button.

You’ll see the results from this action in the update message towards the top of the screen.

Note: the output is generated by WordPress’ built in database modification function and will report that a table was ‘created’ whether it already exists or not. If you see the ‘Created table xxx’ message for a table you’ve already created, it just means the table definition was passed through WordPress’ internal database modification process and any available modifications will have been applied to the table. Your data is still there, but in the unlikely event where data is lost, you’ll have your back up to roll back to.

Table creation is now done. Any data you save for the relevant object (post, user) will now be stored in the custom database table.

Spot an issue? Please let us know about it.

Good dev stuff, delivered.

Product news, tips, and other cool things we make.

We never share your data. Read our Privacy Policy

© 2016 – 2024 Hookturn Digital. All rights reserved.