function _privatemsg_delete_data in Privatemsg 7
Same name and namespace in other branches
- 7.2 privatemsg.module \_privatemsg_delete_data()
Delete all message data from a user.
2 calls to _privatemsg_delete_data()
- privatemsg_user_cancel in ./
privatemsg.module - Implements hook_user_cancel().
- privatemsg_user_delete in ./
privatemsg.module - Implements hook_user_delete().
File
- ./
privatemsg.module, line 1310 - Allows users to send private messages to other users.
Code
function _privatemsg_delete_data($account) {
$mids = db_select('pm_message', 'pm')
->fields('pm', array(
'mid',
))
->condition('author', $account->uid)
->execute()
->fetchCol();
if (!empty($mids)) {
// Delete recipient entries in {pm_index} of the messages the user wrote.
db_delete('pm_index')
->condition('mid', $mids)
->execute();
}
// Delete messages the user wrote.
db_delete('pm_message')
->condition('author', $account->uid)
->execute();
// Delete recipient entries of that user.
db_delete('pm_index')
->condition('recipient', $account->uid)
->condition('type', array(
'user',
'hidden',
))
->execute();
// DELETE any disable flag for user.
db_delete('pm_disable')
->condition('uid', $account->uid)
->execute();
}