function registration_user_delete in Entity Registration 8
Same name and namespace in other branches
- 7 registration.module \registration_user_delete()
Implements hook_user_delete().
File
- ./
registration.module, line 412
Code
function registration_user_delete(\Drupal\user\UserInterface $account) {
if ($account
->id() != NULL) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'registration')
->propertyCondition('author_uid', $account
->id())
->execute();
if ($result) {
registration_delete_multiple(array_keys($result['registration']));
}
// Users associated with {registration}.user_uid do not own the
// registration. Simply disassociate the user with the registration.
db_update('registration')
->fields(array(
'user_uid' => NULL,
))
->condition('user_uid', $account
->id())
->execute();
// Delete entries in the cache as well.
cache_clear_all('*', 'cache_entity_registration', TRUE);
}
}