XF 2.2 delete a user and delete him from everywhere

Robert9

Well-known member
Is there a nice function to send a table_name and condition to delete {something} for this user_id
when a user is deleted?

example
table_id, color_id, user_id

delete from example where user_id = ?
 
Code event listeners -> user_delete_clean_init

PHP:
    public static function userDeleteCleanInit(\XF\Service\User\DeleteCleanUp $deleteService, array &$deletes)
    {
        $deletes['xf_your_table_name'] = ['user_id = ?'];
    }

// or if more than one user_id is stored in your table
    
    public static function userDeleteCleanInit(\XF\Service\User\DeleteCleanUp $deleteService, array &$deletes)
    {
        $deletes['xf_your_table_name'] = ['user_id = ?', 'other_user_id = ?'];
    }
 
Back
Top Bottom