How to set the default role when user log in in liferay 6.0 or 6.1

Kiran Kumar Boyini, modified 13 Years ago. Expert Posts: 287 Join Date: 6/2/11 Recent Posts
Hi All,

I have requirement i.e., When the user logs in we have to assign one role as default role from the available roles related to him.
And he has in role (default role) every time, when he logs.

Tell me, how it is possible in simplest way.

Regards,

Kiran.
thumbnail
Jitendra Rajput, modified 13 Years ago. Liferay Master Posts: 875 Join Date: 1/7/11 Recent Posts
over ride login.events.post event using hook. This event will be called after successful login.

Specify below entries in your liferay-hook.xml

<hook>
<event>
<event-class>com.test.sample.CustomLoginPostAction</event-class>
<event-type>login.events.post</event-type>
</event>
</hook>



And create CustomLoginPostAction class and write your logic to associate default role with logged in user.



public class LoginPostAction extends Action {



You can get logged in users details using PortalUtil.getUserId(request);
To know more about this check LoginPostAction inside portal source
thumbnail
Sreeraj AV, modified 13 Years ago. Regular Member Posts: 239 Join Date: 4/27/10 Recent Posts
Kiran Kumar Boyini:
Hi All,

I have requirement i.e., When the user logs in we have to assign one role as default role from the available roles related to him.
And he has in role (default role) every time, when he logs.

Tell me, how it is possible in simplest way.

Regards,

Kiran.


I didnt get ur question exactly.. One option is, using control panel section. We can set default users associations using Control Panel -> Portal Settings -> Users -> Default User Associations Tab.