Delete Account
Delete Account
The Kirby Kart plugin can perform a "soft" delete on a user account. It does not remove the Kirby user account but changes the role from customer
to deleted
to retain relations to orders. It will reset the password and since the role changed the user will not be able to login or register anew with magic links. Soft deleted accounts are not considered "customers" by the Kirby Kart plugin.
You can use the following code to create a form for account deletion.
site/snippets/kart/account-delete.php
<form method="POST" action="<?= kart()->urls()->account_delete() ?>">
<button type="submit"
onclick="if(confirm('Are you sure you want to delete your account?')) { this.disabled=true; this.form.submit(); } return false;">Delete Account</button>
</form>
If you need to perform additional tasks when the user deletes their account consider registering the the kart.user.softDeleted
-hook.
site/config/config.php
<?php
return [
'hooks' => [
'kart.user.softDeleted' => function (?User $user = null): void {
// TIP: a discord notification to yourself
// or delete the account for real with $user->delete();
},
],
// other options
];