Hello guys
Here, I assign custom created roles to user from custom portlet in liferay 6.2.
I create three regular roles i.e vendor, client and standard user from liferay portal.
Now, I assign the role to particular user from liferay portlet using below java code :
try {
User newUser = .....
Role role = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), "client");
System.out.println("Found role : " + role.getRoleId());
RoleUtil.addUser(role.getRoleId(), newUser.getUserId());
UserLocalServiceUtil.updateUser(newUser);
} catch (Exception e) {
e.printStackTrace();
}
0 Comment(s)