I can suggest you download 5.2 incase your editing it incorrectly but I dont see an issue with the line here is the code block so your still not getting $username defined
$uid is already defined and when I click from a profile delete all photos by this user it works right with the code mentioned.
Code:
Content visible to verified customers only.