Neos\Neos\Command\UserCommandController::deleteCommand PHP Method

deleteCommand() public method

This command deletes an existing Neos user. All content and data directly related to this user, including but not limited to draft workspace contents, will be removed as well. All accounts owned by the given user will be deleted. If an authentication provider is specified, this command will look for an account with the given username related to the given provider. Specifying an authentication provider does not mean that only the account for that provider is deleted! If a user was found by the combination of username and authentication provider, all related accounts will be deleted.
public deleteCommand ( string $username, boolean $assumeYes = false, string $authenticationProvider = null ) : void
$username string The username of the user to be removed
$assumeYes boolean Assume "yes" as the answer to the confirmation dialog
$authenticationProvider string Name of the authentication provider to use. Example: "Typo3BackendProvider"
return void
    public function deleteCommand($username, $assumeYes = false, $authenticationProvider = null)
    {
        $user = $this->getUserOrFail($username, $authenticationProvider);
        if ($assumeYes === true) {
            $delete = true;
        } else {
            $delete = $this->output->askConfirmation(sprintf('Are you sure you want to delete the user "%s" (%s) including all directly related data? (y/n) ', $username, $user->getName()));
        }
        if ($delete) {
            $this->userService->deleteUser($user);
            $this->outputLine('Deleted user "%s".', array($username));
        }
    }