0
votes

I'm currently developing a Joomla component and I'm totally stuck. I want to add a bunch of users to Joomla 2.5 and I theoretically know how to do, but it doesn't work. More specific: The creation of passwords doesn't work as expected...

I'm using the following code to create the user's password :

jimport('joomla.user.helper');

foreach($users as $user)
{
    $salt = JUserHelper::genRandomPassword(32);
    $crypt = JUserHelper::getCryptedPassword('foo', $salt);
    $password = $crypt.":".$salt;
}

If I try this code inside of the default view default.php it works as it should. But if I use the same code inside of the controller it raises an Internal Server Error 500.

I don't understand why this doesn't work inside of the controller ...

Does someone know an answer?

Max

Edit: It seems to be something about the foreach loop... The code works everywhere in the controller besides inside of the loop

1
Users is an array of user objects?Elin

1 Answers

0
votes

I think good way is to observe the component com_adduserfrontend, more in details please observe file:components/com_adduserfrontend/views/adduserfrontend/tmpl/default.php

The component set the password like this:

jimport( 'joomla.user.helper' );

$createpassword = createRandomPassword();

$password = getCryptedPassword($createpassword, $salt= '', $encryption= 'md5-hex', $show_encrypt=false);

$showpass = $createpassword;

Hope this helps!