GravityRevisions hooks
This is a list of the developer hooks (filters and actions) available in the GravityRevisions plugin, covering both entry revisions and form revisions. They use WordPress’ add_filter() and add_action() functions. The complete, always-current reference for every hook, with parameters and the version each was added in, lives on our developer documentation site: GravityRevisions on gravitykit.dev.
gravityview/entry-revisions/list-html/output
Filters the output for the revisions list HTML.
| type | parameter | description |
|---|---|---|
| string |
$output
|
If the entry is not found, outputs “revision not found” message. On “Entry Details” pages where the current entry is a revision, the output is a link to the entry comparison. |
| array |
$entry
|
The entry connected to the displayed revisions. |
| array |
$revisions
|
Array of revisions being rendered by the method. |
gravityview/entry-revisions/revision-title
Filters the revision title, which is used when rendering the revision list and the comparison (“diff”) table caption.
| type | parameter | description |
|---|---|---|
| string |
$revision_title
|
Existing revision title |
| array |
$revision
|
The revision entry array |
| array |
$revision_details
|
Additional information used in the title, passed as associative array. Keys include format, gravatar, author, date, current_entry
|
gravityview/entry-revisions/diff-ignored-keys
Specify the field IDs and meta keys to not display in the diff table
| type | parameter | description |
|---|---|---|
| array |
$ignored_keys
|
Array of field and meta keys, like [ "id", "date_updated", "1.2" ]
|
| array |
$form
|
The form connected to the entry/revision diff being displayed |
gravityview/entry-revisions/restore/remove-gf-hooks
Modify whether to remove Gravity Forms hooks when restoring an entry.
| type | parameter | description |
|---|---|---|
| bool |
$remove_hooks
|
Whether to remove Gravity Forms hooks when restoring an entry. [Default: true] |
| int |
$entry_id
|
ID of entry being restored to |
gravityview/entry-revisions/restore/add-new
Modifies whether—when creating a revision—a new revision should be created with the prior state.
| type | parameter | description |
|---|---|---|
| bool |
$add_new
|
Should a new revision be created based on the entry before the restoration? [Default: true] |
| array |
$prior_entry
|
Entry before restoring values |
| array |
$new_entry
|
Current entry, after restoring values |
gravityview/entry-revisions/restore/delete-after
Modifies whether a revision should be deleted after it has been restored.
| type | parameter | description |
|---|---|---|
| bool |
$remove_after_restore
|
Should a revision be deleted after restoration? [Default: false] |
| int |
$revision_id
|
ID of revision being restored |
| int |
$entry_id
|
ID of connected entry |
gravityview/entry-revisions/diff-row-args
Modify how the diff rows are rendered.
| type | parameter | description |
|---|---|---|
| array |
$diff_row_args
|
Args passed to
|
| array |
$context
|
Additional information about the current row being rendered.
|
Example:
/**
* Modify the "No Value" message in the comparison table when there was nothing set for the field
*/
add_filter( "gravityview/entry-revisions/diff-row-args", function( $diff_row_args ) {
$diff_row_args["empty_value"] = "null"; // Previously: "<em>No Value</em>"
return $diff_row_args;
} );gravityview/entry-revisions/show-filter-links
In Gravity Forms’ Entry List table, there are filter links to filter entries. By default, the plugin adds an “Entry Revisions” link. Use this filter to disable adding that link by returning false.
| type | parameter | description |
|---|---|---|
| bool |
$show_filter_links
|
True: show the “approved”/”disapproved” filter links. False: hide them. [Default: true] |
| array |
$form
|
Gravity Forms form object of the current form |
Example:
add_filter( "gravityview/entry-revisions/show-filter-links", "__return_false" );gravityview/entry-revisions/embed-css
Modify whether to include embedded <style> HTML tag with inline CSS rules with the output of the {entry_revision_diff} Merge Tag.
| type | parameter | description |
|---|---|---|
| bool |
$embed_css
|
Whether to embed the CSS tag. [Default is determined by whether a notification is currently being sent] |
gravityview/entry-revisions/send-notifications
Whether to trigger or suppress send notifications when an entry revision is added. (Added in 1.0.2)
| type | parameter | description |
|---|---|---|
| bool |
$send_notification
|
Should a notification be sent when a revision is created? [Default: true] |
| array |
$revision_to_add
|
The new revision added |
| array |
$current_entry
|
The replaced entry |
| array |
$changed_fields
|
The new entry, with only the changed fields |
Form revision actions #
Added in GravityRevisions 1.9.0. These actions fire around form revisions: the versions of a form saved from the form editor and, since 1.9.0, from the Notifications and Confirmations screens. Each form revision includes the form’s notifications and confirmations. Use them with add_action().
gk/gravityrevisions/form-revisions/save/before
Fires before a form revision is stored.
int $form_idForm ID the revision belongs toarray $form_metaNormalized form meta about to be stored
gk/gravityrevisions/form-revisions/save/after
Fires after a form revision has been stored.
int $revision_idThe newly created revision IDint $form_idForm ID the revision belongs toarray $form_metaForm meta that was stored
gk/gravityrevisions/form-revisions/restore/before
Fires before a form is restored to a revision. GravityRevisions saves the current form as a new revision before overwriting it, so a restore can be undone.
int $form_idForm ID being restoredint|string $revision_idRevision ID being restored to
gk/gravityrevisions/form-revisions/restore/after
Fires after a form has been restored to a revision, including its notifications and confirmations.
int $form_idForm ID that was restoredint|string $revision_idRevision ID that was restored to
gk/gravityrevisions/form-revisions/delete/before
Fires before a form revision is deleted.
int $revision_idThe revision ID being deleted
gk/gravityrevisions/form-revisions/delete/after
Fires after a form revision has been deleted. It does not fire when the revision ID did not exist.
int $revision_idThe revision ID that was deleted
Entry revision actions #
gk/gravityrevisions/entry-revisions/restore/after
Added in GravityRevisions 1.9.0. Fires after an entry has been restored from a revision. Restoring suppresses Gravity Forms’ entry update hooks so notifications and feeds don’t fire again, which means anything that caches entry data (a calendar subscription, a search index) has nothing else to listen for. Use this action to react to a restore.
int $entry_idThe restored entry’s IDarray $entry_beforeThe entry as it was before the restorearray $entry_restoredThe entry after the restoreint $revision_idThe revision that was restored
Example:
add_action( 'gk/gravityrevisions/entry-revisions/restore/after', function ( $entry_id, $entry_before, $entry_restored, $revision_id ) {
// Refresh anything that caches this entry, e.g. clear a transient or rebuild an index.
}, 10, 4 );