XF 2.0 Cleaning up data after User delete

Kirby

Well-known member
I am currently working on some cleanup code for systems external to XenForo (Newsletter, Ticket System, etc.).
To do so, I need to access the email address of the deleted user(s), however I don't see a nice way to do this:

XF\Entity\User::_postDelete()
PHP:
protected function _postDelete()
{
    [...]

    if ($this->getOption('enqueue_delete_cleanup'))
    {
            $this->app()->jobManager()->enqueue('XF:UserDeleteCleanUp', [
                    'userId' => $this->user_id,
                    'username' => $this->username
            ]);
    }
}

and

XF\Job\UserDeleteCleanUp::run()
PHP:
public function run($maxRunTime)
{
    /** @var \XF\Service\User\DeleteCleanUp $deleter */
    $deleter = $this->app->service(
            'XF:User\DeleteCleanUp', $this->data['userId'], $this->data['username']
    );
}

Does anyone have an idea on how to get the email (apart from completely overwriting those methods)?

If not: Would it be possible and reasonable to add the email to the core code, @ChrisD?
 
Yeah, but I need it in XF\Service\User\UserDeleteCleanUp

Doing the cleanup (which might take quite some time) inline in _postDelete() doesn't seem to be a good idea.
 
You probably won't be able to get it there since only user_id and username are passed and by that point the user's data has already been deleted. Probably would be best off creating a separate job that deletes the data you need and then enqueue it yourself after the DeleteCleanUp job
 
Top Bottom