Joomla User Update

omidhz 14 Jun, 2017
I'm trying to create a form that my user can update their password. I'm using the Joomla Save User element in the setup for this purpose, but unfortunately, when I use that I get an error that user already exist. I'm not sure how I can have this done.
Here is a screenshot of how I setup my Save User action.
[attachment=23207_20170614042405_capture-jpg.jpg][/attachment]
GreyHead 14 Jun, 2017
Answer
1 Likes
Hi omidhz ,

I believe that the Save User action is designed to create a new user with all the info, if you just want to update the password then you'll need to use the Joomla! JUser object code in a Custom Code action in your form. Note that Joomla! does not save the password, - just a hashed string that can be used to match the password.

Bob
omidhz 15 Jun, 2017
1 Likes
I was able to make this form and it now works beautifully. If anyone else is interested, here is what I have done:
1- Create two text fields "new_password" and "new_password_confirm".
2- In setup, add a custom php code and enter the following:
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($this->data['new_password'], $salt);
$this->data['password'] = $crypt.':'.$salt;

3 - Add Save Data element after that with the following setting:
[list]- Auto manage the data table: OFF
- Database table: xxx_users
- Data provider: {data:}
- Write action: Update
- Data override on Insert: EMPTY (delete everything that is there
- Dataoverride on Upda: password:{data:password}
- Auto save fields: OFF
- Update conditions: id:{user:id}
- Special fields: EMPTY[/list]
Here is a screenshot for better understanding
[attachment=23207_20170615011719_capture-jpg.jpg][/attachment]
This topic is locked and no more replies can be posted.