掲示板

Create user and tagged to the role based on online parameter

7年前 に LR BEGINNER によって更新されました。

Create user and tagged to the role based on online parameter

New Member 投稿: 24 参加年月日: 16/07/21 最新の投稿
Hi All,

I'm using liferay 6.2 and i'm wondering wheher there's a way to create user and tagged to the role based on online parameter. For example, if user select "Buyer" role, then this user will be created in user_ table and tagged to "Buyer" role in users_roles. There can be more than 1 role.
Thanks in advance.
thumbnail
7年前 に Samuel Kong によって更新されました。

RE: Create user and tagged to the role based on online parameter

Liferay Legend 投稿: 1902 参加年月日: 08/03/10 最新の投稿
You can use the method UserLocalServiceUtil.addUser. There's a parameter for specifying the 'roleIds' parameter where you can specify the roles that the user should have.
7年前 に LR BEGINNER によって更新されました。

RE: Create user and tagged to the role based on online parameter

New Member 投稿: 24 参加年月日: 16/07/21 最新の投稿
Thanks Samuel.

I'm trying to use that method, but it throws error when triggering this line below:
UserLocalServiceUtil.addUser(user);

Attached is my file for reference. Any advise would be great. Thanks.
thumbnail
7年前 に Samuel Kong によって更新されました。

RE: Create user and tagged to the role based on online parameter

Liferay Legend 投稿: 1902 参加年月日: 08/03/10 最新の投稿
Don't use the addUser(User) method. Use the one with many parameters instead.
7年前 に LR BEGINNER によって更新されました。

RE: Create user and tagged to the role based on online parameter

New Member 投稿: 24 参加年月日: 16/07/21 最新の投稿
Thanks Samuel, i'm able to add it now using the method suggested by you.

UserLocalServiceUtil.addUser(0, companyId, true, null, null,
false, screenName, emailAddress, facebookId, openId,
themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId,
(gender.equalsIgnoreCase("male")?true:false), calBday.get(Calendar.MONTH), calBday.get(Calendar.DAY_OF_MONTH),
calBday.get(Calendar.YEAR), jobTitle, new long[] {group.getGroupId()},
null, roleids, null, true, serviceContext);