Auto generated passwords when creating a new user with Fabrik 3

Matthews

New Member
When using Fabrik to create a new user, is it possible to have the system generate a password for the user as when creating a user via the backend ie. if the password field is left blank, it will automatically create one.

The form is working fine, but I need this functionality to make my system work as I want. There are currently no validations on the password element but still says 'You must enter a password'

Any help is greatly appreciated :)
 
I'm doing this with a calc element and the user form plugin.
PHP:
$user = &JFactory::getUser();
if ($user->id == 0) {
   $length = 7;
  $key = "";
  // define possible characters
  $possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRTVWXYZ";
  $i = 0;
  while ($i < $length) {
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
      $key .= $char;
      $i++;
  }
  return $key; 
  
}

elseif ($user->id > 0)
{return '***********';}
 
I'd do it with a form submission plugin running on "new" rather than a calc, but that's personal preference.

And just to answer something in the OP ...

There are currently no validations on the password element but still says 'You must enter a password'

That's a J! thing. The JUser API doesn't allow empty passwords for new users, so we catch empty passwords and automatically fail the validation.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top