For various reasons, I need to create a Joomla user from outside Joomla. Following advice, I'm using passwordhash.php for the hashing so I use something like
$t_hasher = new PasswordHash(10, TRUE);
$jpassword = $t_hasher->HashPassword($rsnew["password"]);
Then directly add a record containing name, email, username and this hashed password into the Joomla ..._users table. (I also add the relevant record into the ..._user_usergroup_map table)
The record looks fine in the database but I can't login - "Username and password do not match or you do not have an account yet."
However, I can authenticate successfully from an external program against the Joomla ..._users table using something like...
$mysql = "SELECT password FROM jos_users WHERE username = '".$usr."'";
$t_hasher = new PasswordHash(10, TRUE);
if ($t_hasher->CheckPassword($pwd, $mydb->get_var($mysql))) {
return TRUE;
.........
Obviously the stored password hash is correct in some way otherwise I wouldn't be able to authenticate it from outside but why won't Joomla accept it?
(If I go into Joomla admin and change the password, then I can correctly authenticate from both inside and outside Joomla.)
Any ideas Thanks