Hi all, I am having an issue with changing user email programmatically that causes the user password to be somehow corrupted and subsequently user cannot login. Kindly, allow me to explain.
I have a PHP file that allow the change of the current login user to change his/her email address:
global $user;
$user = user_load($user->uid);
$user->mail = 'user@abc.com';
user_save((object) array('uid' => $user->uid), (array) $user);
After I run this PHP file, the email was changed successfully but it has a very bad side effect. Upon logging off. The user cannot login any more. Somehow the password was changed. I had to reset the password using an Admin account.
Should anyone have any pointers, I'd be very much grateful.
Thanks very much in advance.
Regards,
Chang