This hook allows your plugin to control which optional events are written to the audit trail, allowing you to implement custom auditing policies for when information is read by users of the application.

You should examine the proposed AuditEntry object, and set response.write to true or false according to your policy. If your policy does not affect this entry, do not change the value of response.write.

The defaultWrite argument to the hook function reflects the default policy for this application.

Important: If you implement the hAuditEntryOptionalWrite hook, you must call declareAuditEntryOptionalWritePolicy() on your plugin to describe the policy you implement to the administrator.


Name Type Description
entry AuditEntry The proposed audit entry
defaultWrite boolean Whether the audit entry is configured to be written by default


Return information by changing these properties of the response object.

Name Type Description
write boolean Whether the proposed audit entry should be written

JavaScript template

P.hook('hAuditEntryOptionalWrite', function(response, entry, defaultWrite) {
    // Respond to hook, for example
    // response.write = ...