Removing Field Data from Private Messages When Deleted

When using the Drupal module, Privatemsg, field data associated with private messages will remain in your database after a private message is deleted.

If you would like to remove related field data, including managed files associated with those fields, you can implement hook_privatemsg_message_flush().

/**
* Implements privatemsg_message_flush().
*/
function mymodule_privatemsg_message_flush($message) {
  field_attach_delete('privatemsg_message', $message);
}