strangerstudios / basic-user-avatars

Add an avatar upload field on frontend pages and on the Edit Profile screen so users and admins can manage custom profile pictures without Gravatar.
https://wordpress.org/plugins/basic-user-avatars/
39 stars 34 forks source link

Fix deletion of old avatars before upload of new #79

Open efc opened 7 months ago

efc commented 7 months ago

The current code uses $this->user_id_being_edited as the argument to $this->avatar_delete on line 352, but it does not set this value until line 359. This means that avatar_delete is always getting a null user and never actually deleting anything.

This change uses $user_id as the argument instead, which allows the plugin to delete the old avatars before uploading the new.

Given the text in the description of what will happen on the profile page ("Replace the local avatar by uploading a new avatar"), deleting the old avatars would be the expected behavior. We want to replace the local avatar, not leave it lingering in the uploads directory. This pull request accomplishes the result promised in the description.

Rise-KuN commented 4 months ago

check my reply here delete old image and gif not playing #69