Deleting unclaimed accounts

Since 3.29.0 delete-unclaimed-user (LH_Profile_Delete_Unclaimed_User_Ability, includes/lh-profile-delete-unclaimed-user-ability-class.php) deletes, network-wide, an account that something created automatically and nobody ever claimed: the account email ingestion made for a spam sender, or a typo address copied on a team email. lh-email’s mark-as-spam is meant to call it after its grace period (lh-tasks #151719); it can also be called on its own. It requires install_plugins, filterable with lh_profile_delete_unclaimed_user_return_capability.

Checks

Every check must pass, or the call returns step: refused with each check’s result and no token. The checks are:

The whole list is filterable with lh_profile_return_unclaimed_delete_checks: an array of check name => callable taking the WP_User and returning '' to pass or a reason to refuse.

Preview and apply

The confirm token is a site transient keyed by the token’s hash, valid 10 minutes, bound to the actor, the user and the preview’s findings (email, provenance, every check result and the removal counts); the apply re-runs everything and refuses if any of it changed. On apply: LH_Messaging_Store::delete_sender_messages() deletes the messages they sent with their recipient rows and unlinks rows for mail sent to them; unlink_user() clears anything they authored; their BuddyPress invitation rows are deleted; then wpmu_delete_user() removes the account, which also fires LH Phone Numbers’ and BuddyPress’s own cleanup. The deletion is recorded in LH Audit Trail as account.unclaimed_user_deleted (not member-visible, since the account is gone; kept forever), with the email, display name, provenance, removals, the reason as its note and the lh-tasks task_id when given. The lh_profile_unclaimed_user_deleted action fires with the user ID, that record, the reason and the task ID.

Gotchas