Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Lukas Barina
API to change existing site member role from site member to site admin
February 27, 2013 4:16 AM
Answer

Lukas Barina

Rank: New Member

Posts: 8

Join Date: June 7, 2012

Recent Posts

Hi,
anybody who knows the API to change site members roles ???

I have a concreate site with bunch of users as site members
I need to make a concreate user to be a site admin programatically

I tried following code but no luck:
Role role = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), "Site Admin");
long[] roleIds = new long[] { role.getRoleId() };
long[] groupIds = new long[] { mySite.getGroupId() };

// GroupLocalServiceUtil.addRoleGroups(role.getRoleId(), groupIds); ??
UserGroupRoleLocalServiceUtil.addUserGroupRoles(adminUser.getUserId(),mySite.getGroupId(), roleIds);

Any help appriciated

--Lukas