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:
$user = user_load($user->uid);
$user->mail = 'firstname.lastname@example.org';
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.