Board: 1.10.3 "Hyacinthe"
Module: FrontEndUsers 1.17
Just found this bug and wish to create this post to avoid you from troubles

When we needs to register some new user from code, we usually work by this steps:
1) Check if username not used already by some one else
2) If not, register user.
3) Check if user present in system now
When I was try to release this steps I was found this approach impossible, look

1) CHECK
Code: Select all
$feu = $this->GetModuleInstance('FrontEndUsers');
$uinfo = $feu->GetUserInfoByName( $username );
if( !is_array($uinfo) || $uinfo[0] != FALSE )
{
// All right at this time new user not found! And we do not step here.
}
I like to use SelfRegistration at this step, which I give proper formated $params array.
Code: Select all
$this->GetModuleInstance('SelfRegistration')->DoAction('reguser', 0, $params);
Code: Select all
$uinfo = $feu->GetUserInfoByName( $username );
if( !is_array($uinfo) || (is_array($uinfo) && $uinfo[0] == FALSE) )
{
// Ha-ha we always step here! while actually user was added to db already, but we do
// not know it and step to this place, where we think that user
// was no added at all!
}
Code: Select all
$_useridbyname == array ( 'SomeUserName' => 'invalid',)

So, the question is: How to do the right check of username before add the user?

You may get all users in default group by
Code: Select all
$feu->GetFullUsersInGroup($feu->GetPreference('default_group'))
In good style, you need to add cache refresh method to FrontEndUsers.