[英]Assigning roles to a user in registration process [yii (users + auth)]
我在Yii中使用用户+身份验证模块。 我已经使用管理在auth中做了3个角色:
auth/role/
另外,在用户模块中
user/profileField
我已经创建了一个个人资料字段,该字段将在注册页面中确定,您要创建哪个帐户
[boolean: true="Company" false="Other"]
管理员帐户只能在模块中创建
我想在注册过程中基于此字段分配角色。 我想我应该用这种方法写这个(?):
/user/controllers/RegistrationController.php:
public function actionRegistration(){...
...
if ($model->save()) {
$profile->user_id=$model->id;
....my role assign here ?...
$profile->save();
...
顺便说一句:直接更改/user/controllers/RegistrationController.php是否优雅?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.