Fórum

getting role id

thumbnail
yan paing, modificado 13 Anos atrás.

getting role id

Regular Member Postagens: 128 Data de Entrada: 11/03/10 Postagens Recentes
Hi everyone,

I would like to know that how can i get role id.
Is there any API to get the role id.

Thanks in advance,
Yan
thumbnail
José Manuel Domínguez Romero, modificado 13 Anos atrás.

RE: getting role id

Regular Member Postagens: 219 Data de Entrada: 03/02/10 Postagens Recentes
Hello,

final Role user = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);

And with user.getRoleId(), you've got the roleid.


Regards
thumbnail
yan paing, modificado 13 Anos atrás.

RE: getting role id

Regular Member Postagens: 128 Data de Entrada: 11/03/10 Postagens Recentes
Hi Jose,

Thanks for your quick reply.
Actually i want to know the current login user's role id.

Thanks and Regards,
Yan
thumbnail
Ravi Kumar Gupta, modificado 13 Anos atrás.

RE: getting role id

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
yan paing:

Actually i want to know the current login user's role id.


Here you just need to get the curernt logged in user and then get the roleIds.

ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser();
long[] roleIds = user.getRoleIds();


Thanks and Regards
Ravi Kumar Gupta
thumbnail
Ashok Kumar, modificado 9 Anos atrás.

RE: getting role id

Junior Member Postagens: 27 Data de Entrada: 16/11/11 Postagens Recentes
Thanks, this was exactly what I needed.
I used it to get the Site Member Role ID.

final Role siteMemberRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.SITE_MEMBER);