0

I'm creating a new user (v3.x) via a module helper function.

the helper function is called via AJAX. this all works fine.

I'm having trouble getting the user registration to work.

I've previously written this for a back end component and thought the code would just move across but it doesn't any help would be great:

            $data['name'] = $userName;
            $data['username'] = $userName;
            $data['email1'] = $email;
            $data['email2'] = $email1;
            $pwd = md5($password1);
            $data['password1'] = $pwd;
            $data['password2'] = $pwd;

            $language = JFactory::getLanguage();

            $language->load('com_users', JPATH_SITE, 'en-GB', true);

            JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_users/models');


            $model = JModelLegacy::getInstance('Registration', 'UsersModel');

            $return = $model->register($data);

closed as off-topic by mickmackusa, Terry Carter, TryHarder, Zollie, Lodder Apr 4 at 13:24

  • This question does not appear to be about Joomla! administration and development, within the scope defined in the help center
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Joomla 3 doesn't use md5 for hashing passwords? Please don't use it – Lodder Mar 17 at 20:15
  • 4
    I'm voting to close this question as off-topic: typo because the issue was the result of a single character typo which will have no value to future researchers. – mickmackusa Mar 22 at 8:54
0

Okay so fixed the problem with this (and accounted for the MD5 issue)

            $data['name'] = $userName;
            $data['username'] = $userName;
            $data['email1'] = $email1;
            $data['email2'] = $email1;
            $data['password1'] = $pwd;
            $data['password2'] = $pwd;

            $language = JFactory::getLanguage();

            $language->load('com_users', JPATH_SITE, 'en-GB', true);

            JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_users/models', 'UsersModel');

            $model = JModelLegacy::getInstance('Registration', 'UsersModel', array('ignore_request' => true));

            $return = $model->register($data);

Okay so this wasn't just a typo!

I wasn't using the api to the core correctly . Although there was a minor typo in the email actually I also fixed the user models with the correct calls into the API to get it to work correctly.

In regards to encryption this provides Joomla encryption since it uses the Joomla Users model. So by using the Joomla API I don't actually need to encrypt anything. Worth pointing out that the website is SSL certificated so the password is passed to the site in an encrypted manner so exposure of the password happens in a "standard" way.

  • excellent, please mark your question as solved – Riccardo Zorn Mar 18 at 16:21
  • I hope some encryption is happening here, I don't know the core well enough to say at first glance. – mickmackusa Mar 21 at 22:34
  • Storing unencrypted passwords is super, super bad. – mickmackusa Mar 21 at 23:01
  • So did you add a 1 to your snippet to fix it? When you post answers here, it is helpful if you clearly state how/why your solution works. (That said, a typo question is low-value to begin with.) – mickmackusa Mar 21 at 23:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.