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);
Somehow the user-id should be retrievable. It would be ok to use:
$return = $model->register($user);
$user_id = $model->user->id;
You can only get "useractivate" or "adminactivate" when te useractivation-parameter is set to 1 or 2.
Joomla 3.4.8 and above
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";
}
Labels |
Added:
?
|
@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();
Agree so we can close here as expceted behavior as the ID can be get by run $db->insertid();
?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-13 07:28:48 |
Closed_By | ⇒ | brianteeman |
Closed based on comments above
@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:
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?