function comment_user_cancel
comment_user_cancel($edit, $account, $method)
Implements hook_user_cancel().
File
- core/modules/comment/comment.module, line 517
- Enables users to comment on published content.
Code
function comment_user_cancel($edit, $account, $method) { switch ($method) { case 'user_cancel_block_unpublish': $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id())); foreach ($comments as $comment) { $comment->setPublished(CommentInterface::NOT_PUBLISHED); $comment->save(); } break; case 'user_cancel_reassign': /** @var \Drupal\comment\CommentInterface[] $comments */ $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id())); foreach ($comments as $comment) { $comment->setOwnerId(0); $comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous')); $comment->save(); } break; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!comment!comment.module/function/comment_user_cancel/8.1.x