Called when user is about to be deleted
@param object $user
@return void
182195
public function user_delete($user) {
        global $DB;

        $sql = "SELECT e.*
                  FROM {enrol} e
                  JOIN {user_enrolments} ue ON (ue.enrolid = e.id)
                 WHERE e.enrol = :name AND ue.userid = :userid";
        $params = array('name'=>$this->get_name(), 'userid'=>$user->id);

        $rs = $DB->get_recordset_sql($sql, $params);
        foreach($rs as $instance) {
            $this->unenrol_user($instance, $user->id);
        }
        $rs->close();
    }
1077062
public function grantTo($user): void
    {
        $userModel = config('auth.providers.users.model');

        if (is_int($user) && !$userModel::find($user)) {
            return;
        }

        $this->users()->attach($user);
    }
47363
private function deleteAuthtokens(Entity\Users $user)
    {
        /** @var Repository\AuthtokenRepository $repo */
        $repo = $this->em->getRepository(Entity\Authtoken::class);
        $repo->deleteTokens($user->getId());
    }
937119
public function unLikeIt($user = null)
    {
        if ($like = $this->isLiked($user)) {
            $like->delete();
            $this->decrementCount();
        }
    }
185946
public function preUpdate(User $user, PreUpdateEventArgs $event)
    {
        if ($event->hasChangedField('avatarImage')) {
            $oldAvatarImage = $event->getOldValue('avatarImage');
            if (!empty($oldAvatarImage)) {
                $this->userService->deleteAvatar($oldAvatarImage);
            }
        }
    }
372260
private function cleanProperties(User $user)
    {
        $sql = 'DELETE FROM `edit_presets` WHERE usr_id = :usr_id';
        $stmt = $this->appboxConnection->prepare($sql);
        $stmt->execute([':usr_id' => $user->getId()]);
        $stmt->closeCursor();

        $this->cleanSettings($user);
        $this->cleanTokens($user);
        $this->cleanQueries($user);
        $this->cleanFtpCredentials($user);
        $this->cleanOrders($user);
        $this->cleanFtpExports($user);
        $this->cleanAuthProvider($user);
        $this->cleanUserSessions($user);
        $this->cleanOauthApplication($user);
    }
1181406
public function updateAction(User $user)
    {
        $this->userService->updateUser($user);
        $this->addFlashMessage('Your user has been updated.', 'User updated', Message::SEVERITY_OK);
        $this->redirect('edit');
    }
557921
private void preDelete(User user) throws Exception
   {
      for (UserEventListener listener : listeners)
      {
         listener.preDelete(user);
      }
   }
210500
public function deleteUser(User $user)
    {
        execute(new RemoveUserCommand($user));

        return cachet_redirect('dashboard.team')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
    }
1296049
public static function user_deleted(\core\event\user_deleted $event) {
        $userid = $event->objectid;
        subscription_manager::delete_user_subscriptions($userid);
    }
467138
public function persist($user): void
    {
        $this->om->persist($user);
        $this->om->flush();
    }
872402
public function setUser(/* string */ $user) {
		// Close connection before changing username.
		if ($this->user !== $user) {
			$this->close();
			$this->user = $user;
		}
	}
166274
public function delete($user)
    {
        if (!is_object($user)) {
            $user = $this->find($user);
        }

        if ($user instanceof User) {
            if ($this->fireEvent('deleting', array($user)) === false) {
                return false;
            }

            $user->delete($this);

            $this->fireEvent('deleted', array($user));
        }
    }
118585
public function ungrantFrom($user): void
    {
        $userModel = config('auth.providers.users.model');

        if (is_int($user) && !$userModel::find($user)) {
            return;
        }

        $this->users()->detach($user);
    }
706564
public function delete_user(string $user): bool
	{
		if ( bbn\str::check_name($user) ){
			$this->db->raw_query("
			REVOKE ALL PRIVILEGES ON *.*
			FROM $user");
			return (bool)$this->db->query("DROP USER $user");
		}
		return false;
	}
402738
public function removeUser(\FOM\UserBundle\Entity\User $user)
    {
        $this->users->removeElement($users);
    }
509658
public function preRemove($object): void
    {
        /** @var BlockAdmin $block */
        $block = $this->blockManager->get($object);
        $block->preRemove($object);
    }