?
avatar Robdebert
Robdebert
29 Mar 2016

Steps to reproduce the issue

Set the Useractivation-Parameter to 1 or 2. When using the registration-model in your own component (for example, if you need to extend the registration for any case) you have to call:

require_once JPATH_ROOT.DS.'components'.DS.'com_users'.DS.'models'.DS.'registration.php';
$user_id = $model->register($user);

Expected result

Somehow the user-id should be retrievable. It would be ok to use:

$return = $model->register($user);
$user_id = $model->user->id;

Actual result

You can only get "useractivate" or "adminactivate" when te useractivation-parameter is set to 1 or 2.

System information (as much as possible)

Joomla 3.4.8 and above

Additional comments

Could easily be solved: in Line 624 of the registration-Model: Change this

    if ($useractivation == 1)
    {
        return "useractivate";
    }

to this:

    $this->user = $user; // make the user-object available in the object for later use.
    if ($useractivation == 1)
    {
        return "useractivate";
    }
avatar Robdebert Robdebert - open - 29 Mar 2016
avatar brianteeman brianteeman - change - 30 Mar 2016
Labels Added: ?
avatar zero-24
zero-24 - comment - 30 Mar 2016

@wilsonge @Bakual @roland-d can you have a look here?

The description of the method says we return the user ID or false. (https://github.com/joomla/joomla-cms/blob/3.5.0/components/com_users/models/registration.php#L357)

But in fact we have the following return values:

if ($useractivation == 1)
{
    return "useractivate";
}
elseif ($useractivation == 2)
{
    return "adminactivate";
}
else
{
    return $user->id;
}

https://github.com/joomla/joomla-cms/blob/3.5.0/components/com_users/models/registration.php#L651-L662

We can remove the if statments but i guess this break B/C

The solution by @Robdebert would mean we introduce a new public var with the user data.

So the question is should we fix the method or the method description and / or should we introduce a new public var?

avatar roland-d
roland-d - comment - 30 Mar 2016

@zero-24 I wonder if this is the correct way to register a user. I don't think the User model is build to be used like that. If the user activation parameter is set, even 3rd party extensions should adhere to this setting. This way, the setting would be completely ignored.

I am not in favour of adding the public var. You should still be able to get the last inserted ID with $db->insertid();

avatar zero-24
zero-24 - comment - 30 Mar 2016

Agree so we can close here as expceted behavior as the ID can be get by run $db->insertid();?

avatar brianteeman brianteeman - change - 13 Apr 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-04-13 07:28:48
Closed_By brianteeman
avatar brianteeman brianteeman - close - 13 Apr 2016
avatar brianteeman brianteeman - close - 13 Apr 2016
avatar brianteeman
brianteeman - comment - 13 Apr 2016

Closed based on comments above


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9644.

Add a Comment

Login with GitHub to post a comment