You are here

function social_post_user_cancel in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  2. 8.3 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  3. 8.4 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  4. 8.5 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  5. 8.6 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  6. 8.7 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  7. 8.8 modules/social_features/social_post/social_post.module \social_post_user_cancel()
  8. 10.0.x modules/social_features/social_post/social_post.module \social_post_user_cancel()
  9. 10.1.x modules/social_features/social_post/social_post.module \social_post_user_cancel()
  10. 10.2.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);
  }
}