User picture not removed when deleting user in Drupal 7 After creating users with a picture programmatically, and deleting them afterwards, I found out that the pictures (files) were not removed.

I started digging into this problem and found out that this problem also occurs when just adding a user by the UI, uploading a picture and deleting the user.

The picture is not being removed. Also the file remains in the file_usage and in the file_managed tables. They're not marked for deletion, so I guess they will stay there forever. Is this a bug? Or am I missing something?
if you really like to delete user profile picture on user delete event use this code in hook_user_delete($account).

// Load user by using user id
$user = user_load($uid);
// Get file id of profile photo
$fid = $user-&gt;picture-&gt;fid;
// Load the file object
$file = file_load($fid);
// delete profile photo from.
file_delete($file);
// Unset the image object (my case it's 'picture')
unset($user-&gt;picture);
// Save the user
user_save($user);


hope works for you