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?


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.
// Unset the image object (my case it's 'picture')
// Save the user
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.