Fórum
Create user and tagged to the role based on online parameter
LR BEGINNER, modificado 7 Anos atrás.
Create user and tagged to the role based on online parameter
New Member Postagens: 24 Data de Entrada: 21/07/16 Postagens Recentes
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.
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.
Samuel Kong, modificado 7 Anos atrás.
RE: Create user and tagged to the role based on online parameter
Liferay Legend Postagens: 1902 Data de Entrada: 10/03/08 Postagens Recentes
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.
LR BEGINNER, modificado 7 Anos atrás.
RE: Create user and tagged to the role based on online parameter
New Member Postagens: 24 Data de Entrada: 21/07/16 Postagens Recentes
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.
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.
Anexos:
Samuel Kong, modificado 7 Anos atrás.
RE: Create user and tagged to the role based on online parameter
Liferay Legend Postagens: 1902 Data de Entrada: 10/03/08 Postagens Recentes
Don't use the addUser(User) method. Use the one with many parameters instead.
LR BEGINNER, modificado 7 Anos atrás.
RE: Create user and tagged to the role based on online parameter
New Member Postagens: 24 Data de Entrada: 21/07/16 Postagens Recentes
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);
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);