function social_post_user_cancel in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.3 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.4 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.5 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.6 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.7 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 8.8 modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 10.3.x modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 10.0.x modules/social_features/social_post/social_post.module \social_post_user_cancel()
- 10.1.x modules/social_features/social_post/social_post.module \social_post_user_cancel()
Implements hook_user_cancel().
File
- modules/
social_features/ social_post/ social_post.module, line 303 - The Social post module.
Code
function social_post_user_cancel($edit, AccountInterface $account, $method) {
$update = NULL;
switch ($method) {
case 'user_cancel_block_unpublish':
// Unpublish posts.
$update = [
'status' => 0,
];
break;
case 'user_cancel_reassign':
// Anonymize all of the posts for this old account.
$update = [
'user_id' => 0,
];
break;
}
if (!is_null($update)) {
$pids = \Drupal::entityQuery('post')
->condition('user_id', $account
->id())
->execute();
module_load_include('inc', 'social_post', 'social_post.admin');
social_post_mass_update($pids, $update, NULL, TRUE);
}
}