Forums

Change password

calangoloco 10 Dec, 2014
Hi @ll!

How to make a user's password change form?

Thanks in advance!
calangoloco 10 Dec, 2014
I created a form with two text boxes, but does not save the password in the correct format in the table...
GreyHead 10 Dec, 2014
Hi calangoloco,

Joomla! doesn't save passwords, just a copy of a hash. You need to add a Custom Code action to your form On Submit event and add the Joomla! code there to create the hash and save it. You can find the code in the Joomla! Users component somewhere.

Bob
calangoloco 10 Dec, 2014
Answer
Hi GreyHead!

I followed your tip, and researched hash, found in the Joomla documentation an helper that does encryption. The address of the documentation is:
http://api.joomla.org/cms-3/classes/JUserHelper.html

Code to get the id of the logged user in DBRead:
<?php
$user = JFactory::getUser();
return array("id" => $user->get("id"));
?>


Code that calculates and sets the password field the password hash :
<?php
$hash = JUserHelper::hashPassword($form->data['Data']['password']);
$form->data['Data']['password'] = $hash;
?>


Then a dbsave to save.
This topic is locked and no more replies can be posted.