Yeah, the usage in that tutorial is old. I'll be sure to update it so it's up to date. In the meantime you can use the below.
Replace ->usertype, ->gid, and ->gids setting with just the above. Below is a more up to date usage of the API.
Code:
function registerUser( $firstName, $lastName, $email, $username, $password, $approve = 0, $confirm = 0, $usergroups = array() ) {
global $_CB_framework, $_PLUGINS, $ueConfig;
$approval = ( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve );
$confirmation = ( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm );
$user = new \CB\Database\Table\UserTable();
$user->set( 'username', $username );
$user->set( 'email', $email );
$user->set( 'name', trim( $firstName . ' ' . $lastName ) );
$user->set( 'gids', array( (int) $_CB_framework->getCfg( 'new_usertype' ) ) );
$user->set( 'sendEmail', 0 );
$user->set( 'registerDate', $_CB_framework->getUTCDate() );
$user->set( 'password', $user->hashAndSaltPassword( $password ) );
$user->set( 'registeripaddr', cbGetIPlist() );
if ( $approval == 0 ) {
$user->set( 'approved', 1 );
} else {
$user->set( 'approved', 0 );
}
if ( $confirmation == 0 ) {
$user->set( 'confirmed', 1 );
} else {
$user->set( 'confirmed', 0 );
}
if ( ( $user->get( 'confirmed' ) == 1 ) && ( $user->get( 'approved' ) == 1 ) ) {
$user->set( 'block', 0 );
} else {
$user->set( 'block', 1 );
}
$_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$user, &$user ) );
if ( $user->store() ) {
if ( $user->get( 'confirmed' ) == 0 ) {
$user->store();
}
$messagesToUser = activateUser( $user, 1, 'UserRegistration' );
$_PLUGINS->trigger( 'onAfterUserRegistration', array( &$user, &$user, true ) );
if ( $user->get( 'block' ) == 1 ) {
return false;
} else {
return true;
}
}
return false;
}