Quick Reference: Custom Hooks API


The table below provides a quick reference to Custom Hook methods. For full Custom Hooks API documentation, see Custom Hooks API Documentation.

MethodArgumentsDescription
OnNew

IPage page

IUserWriteSession session

This method is invoked after a new content node is created.

Use Cases:

  • Set a value based on an ancestor page's content, such as a banner image or component.

  • Create a component that needs to be used in the page, and then insert the component's ID into a Component element.

  • Add the page to a workflow based on the group that created the new page or the section where the page was made.

OnRename

string oldName

string newName

IPage page

IUserWriteSession session

This method is invoked after a Page is renamed.

Caution
Assigning this method to Page.Name inside the method creates an infinite loop.

Use Cases:

  • Rename a companion piece of content, such as a category or folder.
  • Send a notification to another department so they can update their references to the page.
OnBeforeAssign

IPage page

IUserWriteSession session

This method is invoked before a Page is assigned to a User.

Caution
Calling Page.AssignUser or Page.AssignGroup inside this method creates an infinite loop.
OnAfterAssign

IPage page

IUserWriteSession session

This method is invoked after a Page is assigned to a User.

Caution
Calling Page.AssignUser or Page.AssignGroup inside this method creates an infinite loop.

Use Cases:

  • Create a new version of the page in case the next user makes a mistake.
  • Assign companion content, such as components, to the same user, so they can approve all of the content at once.
OnBeforeCheckIn

IPage page

bool recursive

IUserWriteSession session

This method is invoked before a Page is checked in.
OnAfterCheckIn

IPage page

bool recursive

IUserWriteSession session

This method is invoked after a Page is checked in.

Use Cases:

  • Check in companion content.

  • Double-check content for inherited copy from ancestor pages, such as banner images or components, and reset it if necessary.
  • Send an email to another department so they can update links.
  • Create a copy of the page in a matching site, such as in an international site.

OnBeforeCheckOut

IPage page

bool recursive

IUserWriteSession session

This method is invoked before a Page is checked out.

Use Case:

Check out companion content such as components, so the user can work on all the content at once.
OnAfterCheckOut

IPage page

bool recursive

IUserWriteSession session

This method is invoked after a Page is checked out.
OnBeforeCopy

IPage sourcePage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked before a Page gets copied.

Use Case:

Create a version of a piece of content.

OnAfterCopy

IPage sourcePage

IPage newPage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked after a Page gets copied.

Use Case:

Update a piece of content on the new page to indicate something about the sources, such as the version of the page that was copied or categories that were applied.

OnBeforeDelete

IPage page

UserWriteSession session

This method is invoked before a Page is moved to the recycle folder, where it can be deleted, permanently.

Use Cases:

  • Store information about the page so it can be repaired if you later wish to restore it. Assigned user, publication targets it was marked for, and workflow information can all be useful.
  • Check in the page and create a version so saved content will not be lost.
OnAfterDelete

string pageId

bool permanent

IPage page

IUserWriteSession session

This method is invoked after a Page is moved to the recycle folder.

Use Cases:

  • Notify other departments of the change so they can update their links and references.
  • Create a redirect.
  • Add pertinent information to a smart 404 page.
OnBeforeMarkForPublish

IPage page

bool recursive

IEnumerable markedTargets

IEnumerable unmarkedTargets

IUserWriteSession session

This method is invoked before a Page is marked or unmarked for publish.

Use Case:

Verify that certain data is present, otherwise cancel the action.

OnAfterMarkForPublish

T contentItem

bool recursive

IEnumerable<PublishingTargetWithMarkedVersion> markedTargets

IEnumerable<IPublishingTarget> unmarkedTargets

IUserWriteSession session

This method is invoked after a Page is marked or unmarked for publish.

Use Cases:

  • Mark companion content for publish.
  • Send a notification to another department.
OnBeforeMove

IPage sourcePage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked before a Page is moved to another location.

Use Case:

Cancel the move if the destination is unacceptable.

OnAfterMove

IPage sourcePage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked after a Page is moved to another location

Use Cases:

  • Update section-specific content to match the new section.
  • Cancel the move if the new location is not appropriate.
  • Move companion content to a new organizational structure.
OnBeforePasteSpecial

IPage sourcePage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked before a Page gets copied via special command. On the CMS UI, the Paste Special command is executed via drag-and-drop by pressing Alt instead of Ctrl.

At its core, the Paste Special command is just a copy command, which this hook method invoked.

Use Case:

Ensure certain values are set correctly, and cancel the paste if they aren't.

OnAfterPasteSpecial

IPage sourcePage

IPage newPage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked after a Page gets copied via special command. On the CMS UI, the Paste Special command is executed via drag-and-drop by pressing Alt instead of Ctrl.

At its core, the Paste Special command is just a copy command, which this hook method invoked.

Use Cases:

  • Put the new copy of the page into a new workflow for the destination.
  • Notify another department that the page has been pasted.
  • Update content that may be specific to the new structure that the new page is pasted into.
OnBeforeRollback

IPage page

IUserWriteSession session

This method is invoked before a Page is rolled back to its previous version.
OnAfterRollback

IPage page

IUserWriteSession session

This method is invoked after a Page is rolled back to its previous version.

Use Cases:

  • Check in the page and create a version so the saved content is not lost.
  • Ensure that certain fields still exist on the version to which the rollback will occur, and cancel the request if they don't.
OnBeforeUndoCheckOut

IPage page

bool recursive

IUserWriteSession session

This method is invoked before a Page abandons its checked-out version and goes back to a checked in-state.
OnAfterUndoCheckOut

IPage page

bool recursive

IUserWriteSession session

This method is invoked after a Page abandons its checked-out version and goes back to a checked in-state.

Use Case:

Save information about page content before it's lost by undoing check-out.

OnBeforeCrossLocaleCopy

IPage sourcePage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked before a non-Region-Root Page gets copied to under another Region Root.
OnAfterCrossLocaleCopy

IPage sourcePage

IPage newPage

IPage targetPage

EnumCopyActions relation

IUserWriteSession session

This method is invoked after a non-Region-Root Page gets copied to under another Region Root.

Use Cases:

  • Put the new copy of the page into a new workflow for the destination.
  • Notify another department that the page has been pasted.
  • Update content that may be specific to the new structure that the new page is pasted into.
OnBeforeRegionRootCopy

IPage sourcePage

IPage targetPage

EnumCopyActions relation

string targetLocale

IUserWriteSession session

This method is invoked before a Region Root Page is cloned to another Region Root Page, with lingual maps established between the two Regions.
OnAfterRegionRootCopy

IPage sourcePage

IPage newPage

IPage targetPage

EnumCopyActions relation

string targetLocale

IUserWriteSession session

This method is invoked after a Region Root Page is cloned to another Region Root Page, with lingual maps established between the two Regions.

Use Cases:

  • Ensure that content is set correctly before the copy so that it can be pasted properly, and cancel the copy otherwise.

  • Verify that the destination is correct, otherwise cancel.
OnBeforeEmptyRecycleFolder

IPage recycleFolder

IUserSession session

This method is invoked before all Pages in the recycle folder are permanently removed.

Use Case:

Write a log file of all the items that were inside the recycle folder.

OnAfterEmptyRecycleFolder

IPage recycleFolder

IUserSession session

This method is invoked after all Pages in the recycle folder are permanently removed.

Use Case:

Send an email with the contents of the log file to previous owners of the items that were removed.

OnCategoryCreated

ICategoryNode category

IUserWriteSession session

This method is invoked after a Category Node is created.

Use Case:

Create a matching category in a secondary system, such as a database or marketing system.

OnCategoryRenamed

string oldName

string newName

ICategoryNode category

IUserWriteSession session

This method is invoked after a Category Node was created.

Caution
Assigning to CategoryNode.Name in this method creates an infinite loop.

Use Cases:

  • Rename the category in a matching secondary system.
  • Rename a companion piece of content, such as a folder.
  • Count the number of characters to ensure correct display, otherwise throw an error.
  • Check for and remove special characters.
OnBeforeCategoryDelete

ICategoryNode category

IUserWriteSession session

This method is invoked before a Category Node is deleted.
OnAfterCategoryDelete

ICategoryNode category

IUserWriteSession session

This method is invoked after a Category Node is deleted.

Use Cases:

  • Verify that the category isn't being used, and throw an error if it is.
  • Delete matching categories in secondary systems.
  • Flag for update content that relied on the category.

  • Send a notification to a department.

OnUserCreated

IUser user

IUserWriteSession session

This method is invoked after a User is created.

Use Cases:

  • Create a folder in assets for the user.

  • Create a profile page for the user.
  • Add the user to beginning groups.
OnUserGroupCreated

IUserGroup userGroup

IUserWriteSession session

This method is invoked after a UserGroup is created.

Use Cases:

  • Create a component folder organization and apply security if the group name matches certain criteria.
  • Create organization in the assets areas and apply the new group as security if it matches certain criteria.
OnBeforeUserDelete

IUser user

IUserWriteSession session

This method is invoked before a User is deleted.
OnAfterUserDelete

IUser user

IUserWriteSession session

This method is invoked after a User is deleted.

Use Cases:

  • Flag or move user-specific content for deletion.
  • Transfer all assigned pages to another user.
OnBeforeUserGroupDelete

IUserGroup userGroup

IUserWriteSession session

This method is invoked before a UserGroup is deleted.
OnAfterUserGroupDelete

IUserGroup userGroup

IUserWriteSession session

This method is invoked after a UserGroup is deleted.

Use Cases:

  • Assign any pages that the group controls to a new group.
  • Flag any content that was specific to the group for update or deletion.
OnBeforeWorkflowAdvance

ITransition transition

IUserWriteSession session

This method is invoked before a Workflow advances through a Transition.
OnAfterWorkflowAdvance

ITransition transition

IUserWriteSession session

This method is invoked after a Workflow advances through a Transition.

Use Cases:

  • Verify that information is entered properly.
  • Advance companion content through the same workflow and to the same user or group.
OnBeforePublish

IPublishingTarget pubTarget

bool fullPublish

IEnumerable pagesToPublish

IUserWriteSession session

This method is invoked before a Publishing Task is submitted.

Use Cases:

  • Set a minimum amount of new content before a publish can be done.
  • Set a time limit since the last publish before a new publish can be done.
  • Check for integral content readiness before publishing.
OnPublishComplete

IPublishingTarget pubTarget

bool fullPublish

IEnumerable pagesToPublish

Exception publishError

IUserWriteSession session

This method is invoked after a Publishing Task is completed.

Use Cases:

  • Send a notification to the user that started the publish.
  • Send a notification to administrators if there are errors in the publish.
Warning
In CMS 10.0–10.5, the custom hook method OnPublishComplete failed if an error or cancellation occurred during a publish operation. In CMS 10.5+, the OnPublishComplete method always executes, even after a publish interruption. Developers who relied on the previous behavior in their Custom Hooks code must update their code to account for this change.
OnBeforeEntitySave

IEntity entity

IUserWriteSession session

This method is invoked before any type of Ingeniux CMS CSAPI entity object is saved.
OnBeforeUpload

IUserWriteSession session

ref System.IO.Stream uploadStream

refstring filename

refstring targetPhysicalFolder

This method is invoked before the Ingeniux CMS site's server processes a file upload.
OnAfterUpload

IUserWriteSession session

System.IO.FileInfo uploadedFile

int fileSize

Overloaded method. This method is invoked after the Ingeniux CMS site's server processes a file upload.

Signed 32-bit integer. Framework type: System.Int32.

OnAfterUpload

IUserWriteSession session

System.IO.FileInfo uploadedFile

long fileSize

Overloaded method. This method is invoked after the Ingeniux CMS site's server processes a file upload.

Signed 64-bit integer. .NET Framework type: System.Int64.

OnBeforeLogoutIReadonlyUser userThis method is invoked before a user attempts to log out.
OnAfterLogoutstring loggedOutUserIdThis method is invoked after a user logged out.
OnAssetCategorizationChangeICategoryNode categoryIAsset assetEnumCategorizationAction actionThis method is invoked for an Asset when its categorization changes.
OnPageCategorizationChange

ICategoryNode category

IPage page

EnumCategorizationAction action

This method is invoked for a Page when its categorization changes.
OnBeforeWorkflowAdvanceAsset

ITransition transition

IAsset asset

IWorkflow workflow

IUserWriteSession session

This method is invoked for an Asset before a Workflow advances through a Transition.
OnAfterWorkflowAdvanceAsset

ITransition transition

IAsset asset

IWorkflow workflow

IUserWriteSession session

This method is invoked for an Asset after a Workflow advances through a Transition.
OnNewAsset

IAssetItem asset

Stream file

IUserWriteSession session

This method is invoked after a new Asset node is created.
OnUpdateAsset

IAssetItem asset

Stream newFile

IUserWriteSession session

This method is invoked when an Asset is updated.
OnRenameAsset

string oldName

string newName

IAssetItem contentItem

IUserWriteSession session

This method is invoked after an Asset is renamed.
OnBeforeAssignAsset

IAssetItem contentItem

IUserWriteSession session

This method is invoked before an Asset is assigned to a User.
OnAfterAssignAsset

IAssetItem contentItem

IUserWriteSession session

This method is invoked after an Asset is assigned to a User.
OnBeforeCheckInAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked before an Asset is checked in.
OnAfterCheckInAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked after an Asset is checked in.
OnBeforeCheckOutAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked before an Asset is checked out.
OnAfterCheckOutAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked after an Asset is checked out.
OnBeforeCopyAsset

IAssetItem sourcecontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked before an Asset gets copied.
OnAfterCopyAsset

IAssetItem sourcecontentItem

IAssetItem newcontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked after an Asset gets copied.
OnBeforeDeleteAsset

IAssetItem contentItem

IUserWriteSession session

This method is invoked before an Asset is moved to the recycle folder, where it can be deleted, permanently.
OnAfterDeleteAsset

string contentItemId

bool permanent

IAssetItem contentItem

IUserWriteSession session

This method is invoked after an Asset is moved to the recycle folder.
OnBeforeMarkForPublishAsset

IAssetItem contentItem

bool recursive

IEnumerable markedTargets

IEnumerable unmarkedTargets

IUserWriteSession session

This method is invoked before an Asset is marked or unmarked for publish.
OnAfterMarkForPublishAsset

IAssetItem contentItem

bool recursive

IEnumerable markedTargets

IEnumerable unmarkedTargets

IUserWriteSession session

This method is invoked after an Asset is marked or unmarked for publish.
OnBeforeMoveAsset

IAssetItem sourcecontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked before an Asset is moved to another location.
OnAfterMoveAsset

IAssetItem sourcecontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked after an Asset is moved to another location.
OnBeforeRollbackAsset

IAssetItem contentItem

IUserWriteSession session

This method is invoked before an Asset is rolled back to its previous version.
OnAfterRollbackAsset

IAssetItem contentItem

IUserWriteSession session

This method is invoked after an Asset is rolled back to its previous version.
OnBeforeUndoCheckOutAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked before an Asset abandons its checked-out version and goes back to a checked in-state.
OnAfterUndoCheckOutAsset

IAssetItem contentItem

bool recursive

IUserWriteSession session

This method is invoked after an Asset abandons its checked-out version and goes back to a checked in-state.
OnBeforeCrossLocaleCopyAsset

IAssetItem sourcecontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked before a non-Region-Root Asset gets copied to under another Region Root.
OnAfterCrossLocaleCopyAsset

IAssetItem sourcecontentItem

IAssetItem newcontentItem

IAssetFolder targetcontentItem

IUserWriteSession session

This method is invoked after a non-Region-Root Asset gets copied to under another Region Root.
OnBeforeRegionRootCopyAsset

IAssetItem sourcecontentItem

IAssetFolder targetcontentItem

string targetLocale

IUserWriteSession session

This method is invoked before a Region Root Asset is cloned to another Region Root Asset, with lingual maps established between the two Regions.
OnAfterRegionRootCopyAsset

IAssetItem sourcecontentItem

IAssetItem newcontentItem

IAssetFolder targetcontentItem

string targetLocale

IUserWriteSession session

This method is invoked after a Region Root Asset is cloned to another Region Root Asset, with lingual maps established between the two Regions.
OnBeforeEmptyAssetRecycleFolder

IAssetFolder recycleFolder

IUserSession session

This method is invoked before all Assets in the recycle folder are removed, permanently.
OnAfterEmptyAssetRecycleFolder

IAssetFolder recycleFolder

IUserSession session

This method is invoked after all Assets in the recycle folder are removed, permanently.
OnAfterEntitySave

IEntity entity

IUserWriteSession session

This method is invoked after any type of Ingeniux CMS CSAPI Entity object was saved.