开发者

How to assign custom role automatically on registration?

I am using a hook form alter to override the registration process. I want to assign a custom role that i have defined to the new user. How do i get about doing that?

I see that there is a users_roles table. Would simply making an entry in it with the user id and role id 开发者_C百科do the trick?

Thanks


If every new user is going to get the role of authenticated user by default, why not just set the permissions the way you want them for that role? That way you don't need to mess with the database tables at all.


What Dylan says is an excellent point. There is also a contrib module that you can use that will make it easy to assign a specific role: http://drupal.org/project/autoassignrole


Can you please tell, like do users can different roles based on something they choose during registration.

If thats not the case then solution by DYLAN WEST is the one you should go with.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜