Is there a way that I can remove/delete user profile picture through programing? or How can i override existing image with my new one?
-
2Is there a reason you can't use the UI? If you could explain more about what you're trying to accomplish that would be helpful– Clive ♦Commented Aug 28, 2013 at 14:08
-
Yes because i have custom Layout for user profile page. for that I user my custom tpl file other than user--profile.tpl.php– Pranav GandhiCommented Aug 28, 2013 at 14:16
-
have you investigated api.drupal.org/api/drupal/modules!user!user-picture.tpl.php/7 ?– JimajammaCommented Aug 28, 2013 at 14:35
Add a comment
|
1 Answer
use code below in hook_user_delete($account)
// Load user by using user id
$user = user_load($uid);
// Get file id of profile photo
$fid = $user->picture->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->picture);
// Save the user
user_save($user);