You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I upload new avatar, the avatar file is still visible in Media page (wp-admin/upload.php), not removed from server.
Even when I call manually avatar_manager_delete_avatar($user_id) (from my testing plugin), the file is not removed from server. The function seems broken.
The implementation calls unlink() directly, which does not seems to be best practise. I recommand to use API function wp_delete_attachment() - something like:
function avatar_manager_delete_avatar( $user_id ) {
// Retrieves user meta field based on user ID.
$attachment_id = get_user_meta( $user_id, 'avatar_manager_custom_avatar', true );
if ( empty( $attachment_id ) )
return false;
wp_delete_attachment($attachment_id, true); // delete attachement correctly, force remove - skip trash
// Deletes user meta fields based on user ID.
delete_user_meta( $user_id, 'avatar_manager_avatar_type' );
delete_user_meta( $user_id, 'avatar_manager_custom_avatar' );
// Determines whether Multisite support is enabled.
if ( is_multisite() )
delete_user_meta( $user_id, 'avatar_manager_blog_id' );
// Calls the functions added to avatar_manager_delete_avatar action hook.
do_action( 'avatar_manager_delete_avatar', $user_id );
return true;
}
The text was updated successfully, but these errors were encountered:
When I upload new avatar, the avatar file is still visible in Media page (wp-admin/upload.php), not removed from server.
Even when I call manually
avatar_manager_delete_avatar($user_id)
(from my testing plugin), the file is not removed from server. The function seems broken.The implementation calls unlink() directly, which does not seems to be best practise. I recommand to use API function
wp_delete_attachment()
- something like:The text was updated successfully, but these errors were encountered: