0

What is the best aproace of enriching c5 user's attributes.

I have non C5 table with users information this information was created on old cms (non c5), and im now building new site with c5 would like to know best aproach of migrating users.

Is it good idea to use SQL query or should i use php script for enriching, I already created users in to c5 and manualy added email addresses for "anchor point" for later enrichment.

Would be realy glad if someone could tell or maby could lead to some examples.

4

1 回答 1

0

最后由我自己管理,它相当简单:我将外部用户导出到 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']);
}

资源: 以编程方式注册用户和设置组

用户信息文档(设置属性)

于 2015-07-10T07:43:31.410 回答