GravityMigrate hooks
GravityMigrate’s filters and actions are documented in the GravityMigrate developer reference on gravitykit.dev. That reference is generated from the plugin’s source code, so each hook’s name, parameters and source location there follow the plugin as it changes. Every hook has its own page:
What the hooks cover #
The hooks below exist in GravityMigrate 1.4.0. The defaults are the plugin’s own.
| Hook | What it does |
|---|---|
gk/gravitymigrate/export/batch-size | How many rows an export writes per step. Default 10,000. Lower it when an export runs out of memory or time. |
gk/gravitymigrate/export/row | One row of a table before it is written to the export, with the table name, the column names and the export payload. |
gk/gravitymigrate/export/info | The metadata written to the migration file’s info.json before the file is packaged. |
gk/gravitymigrate/import/data_chunk_sizes | How many rows an import processes per step for each data type. Lower entries or nested_entries to reduce memory use on a large import. |
gk/gravitymigrate/import/download-timeout | The timeout, in seconds, for each hop when an import downloads an uploaded file from the source site. Default 300. |
gk/gravitymigrate/import/max-download-bytes | The largest single file an import downloads from the source site. Default 100 MB. |
gk/gravitymigrate/import/max-dump-file-size | The largest database dump an import accepts from a migration file. Default 2 GiB. |
gk/gravitymigrate/import/upload-url | The URL an uploaded file is downloaded from during an import, taken from the exported entry. |
gk/gravitymigrate/import/pre_dns_get_record_a | Short-circuits the DNS lookup that resolves the source site’s IPv4 addresses before a download. |
gk/gravitymigrate/remote-request-args | The arguments of the requests that check whether the source site is reachable before files are downloaded. |
gk/gravitymigrate/cron/clear-import-interval | How long an uploaded migration file stays on the server after an import. Default 1 hour. |
gk/gravitymigrate/cron/clear-export-interval | How long a finished export stays on the server. Default 3 hours. |
gk/gravitymigrate/upload/after-upload (action) | Runs after a migration file is uploaded and staged for import, with the file path and the password. |
The data types gk/gravitymigrate/import/data_chunk_sizes accepts are forms_views, revisions, entries, uploads, nested_entries, entry_revisions, views_and_posts, addon_feeds, gravityflow, gravityflow_addon_feeds, drafts and rest_api_keys.
Note: An earlier version of this article documented gk/gravitymigrate/export/data_chunk_sizes. That filter does not exist and never ran. If you copied it, replace it with gk/gravitymigrate/import/data_chunk_sizes.
Example #
Lower the import chunk size for entries and nested entries on a site that runs out of memory during an import:
add_filter( 'gk/gravitymigrate/import/data_chunk_sizes', function( $chunk_sizes ) {
$chunk_sizes['entries'] = 100;
$chunk_sizes['nested_entries'] = 100;
return $chunk_sizes;
} );Read here how to add these code samples to your website: Where to put code samples.