最后由我自己管理,它相当简单:我将外部用户导出到 php 数组并使用 c5 用户函数来添加用户,并在丰富他们之后我的示例:
$external_users = array({
array('id'=>'1', 'name'='JON', 'email'=>'blank@blank.blank', 'last_name'=>'DOE', 'attr1'=>'smthing', 'attr2'=>'123'),
array(...), ...
});
foreach($external_users as $singleUser_data){
$email = $singleUser_data['email'];
$ui = UserInfo::getByEmail($email);
if (!is_null($ui)) {
// Email is already in use, so let's not create the user
return;
}
$userData['uName'] = $singleUser_data['name']." ".$singleUser_data['lastname'];
//users later need to reset password
$userData['uPassword'] = 'asd52465465456454asd';
$userData['uPasswordConfirm'] = 'asd52465465456454asd';
//user registererd
$ui = UserInfo::register($userData);
set_new_user_group($ui);
enrichAtributes($ui, $singleUser_data);
}
function set_new_user_group($ui){
// assign the new user to a group
$g = Group::getByName('GroupName');
$u = $ui->getUserObject();
$u->enterGroup($g);
}
function enrichAtributes($ui, $singleUser_data){
$ui->setAttribute('atr_handler1', $singleUser_data['attr1']);
$ui->setAttribute('atr_handler2', $singleUser_data['attr2']);
}
资源:
以编程方式注册用户和设置组
用户信息文档(设置属性)