Hi,
First up, this is my first post and I have only been using Joomla and Chronoforms for a month or so now. Well done, great product and these forums are a great source of data.
I am a bit stuck on my latest issue. I want user to be able to edit their registration details. I have it all working, but I am stuck on the password aspect. I have two Password boxes and a custom server side validation to check that password match. However, when I save to the jos_users table, the password is no longer encrypted and is clear text. As a result the user can't login after "changing" their password. I am saving to jos_users via a DB Save operation.
When they register first day, I am using the Joomla User Registration control which works fine. However that control looks like it is only for create user and not changing/editing.
I am editing additional details as well on my custom "edit details" which I am saving to a separate DB table. That part works fine.
Any pattern that I should follow that will allow me to save password correctly?
Cheers
Mark
First up, this is my first post and I have only been using Joomla and Chronoforms for a month or so now. Well done, great product and these forums are a great source of data.
I am a bit stuck on my latest issue. I want user to be able to edit their registration details. I have it all working, but I am stuck on the password aspect. I have two Password boxes and a custom server side validation to check that password match. However, when I save to the jos_users table, the password is no longer encrypted and is clear text. As a result the user can't login after "changing" their password. I am saving to jos_users via a DB Save operation.
When they register first day, I am using the Joomla User Registration control which works fine. However that control looks like it is only for create user and not changing/editing.
I am editing additional details as well on my custom "edit details" which I am saving to a separate DB table. That part works fine.
Any pattern that I should follow that will allow me to save password correctly?
Cheers
Mark
Hi Mark,
First, I suggest that you change your username here to prevent your email being scraped from the forums :-(
The password isn't saved in the #__users table, just a hash created from it so you need to recreate the hash. Also you should generally avoid writing directly to the #__users table and use the Joomla! User Object methods instead. I think this should do it. The user needs to be logged in and the values set for 'password' and 'password2' need to match:
Bob
First, I suggest that you change your username here to prevent your email being scraped from the forums :-(
The password isn't saved in the #__users table, just a hash created from it so you need to recreate the hash. Also you should generally avoid writing directly to the #__users table and use the Joomla! User Object methods instead. I think this should do it. The user needs to be logged in and the values set for 'password' and 'password2' need to match:
<?php
$passwords = array(
'password' => $form->data['password'],
'password2' => $form->data['password2'],
);
$user = & JFactory::getUser();
$user->bind($passwords);
$user->save();
?>
Not tested and may need debugging!Bob
Thanks Bob. I will give that a go later on.
I just spotted my email as user name. I tried to change it, but in Profile the user name fields is not editable. Any other way of doing this?
Cheers
Mark
I just spotted my email as user name. I tried to change it, but in Profile the user name fields is not editable. Any other way of doing this?
Cheers
Mark
For anyone reading who want to change the name and/or email as well, here is the additional bits of code
<?php
$passwords = array(
'password' => $form->data['password'],
'password2' => $form->data['confirmpassword'],
);
$name = $form->data['name'];
$email = $form->data['email'];
$user = & JFactory::getUser();
$user->bind($passwords);
$user->name = $name;
$user->email = $email;
$user->save();
?>
Hi Mark,
Thanks for that.
Actually it can be a bit simpler still:
Bob
Thanks for that.
Actually it can be a bit simpler still:
<?php
$user_data = array(
'password' => $form->data['password'],
'password2' => $form->data['confirmpassword'],
'name' => $form->data['name'],
'email' => $form->data['email']
);
$user = & JFactory::getUser();
$user->bind($user_data);
$user->save();
?>
Bob
This topic is locked and no more replies can be posted.