Preview:
function pos_core_update_9014($sandbox) {
  $user_ids_to_delete = [32, 30, 29, 28, 27, 24, 22, 20, 16, 15, 14, 13];

  // Delete all cfps where the users are going to be deleted.
  \Drupal::database()->delete('cfp')
    ->condition('user_id', $user_ids_to_delete, 'IN')
    ->execute();

  // Delete all applicants associated to the user that is going to be deleted.
  foreach ($user_ids_to_delete as $user_id_to_delete) {
    $user = \Drupal::entityTypeManager()
      ->getStorage('user')
      ->load($user_id_to_delete);

    if ($applicant_id = $user->get('applicant')->target_id) {
      \Drupal::database()
        ->delete('applicant')
        ->condition('id', $applicant_id)
        ->execute();
    }
    // Delete users.
    $user->delete();
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter