Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Danial Mustofa Habibi
automatic assign Roles to new Created User LIferay 6
April 13, 2012 6:16 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hi there I want to know is there a way to automatic assign roles to created new user in liferay 6.0.6? Any code? for example if someone create new user in liferay using registration page and then I want to automatic assign role tho that user to roles penumpang,,,

thank's
any help would be appreciated

Regards

Dania
Olaf Kock
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 6:33 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 3464

Join Date: September 23, 2008

Recent Posts

Do you need more than this?:

ControlPanel/Portal Settings/Users/Default User Associations
Danial Mustofa Habibi
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 6:55 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Olaf Kock:
Do you need more than this?:

ControlPanel/Portal Settings/Users/Default User Associations


Hi there thank's for your answer. That's really helped , at first I Thought i need to do some coding, so I don't need any code to achieved this?


Regards

Danial
Hitoshi Ozawa
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 6:57 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Hi there I want to know is there a way to automatic assign roles to created new user in liferay 6.0.6?


Just as a note, when using "Default User Associations", you'll have to setup the defaults BEFORE creating your users.
Olaf Kock
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 7:11 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 3464

Join Date: September 23, 2008

Recent Posts

Correct, no coding - for any users created after you configured this, as Hitoshi pointed out what I missed in my initial answer.
It might be advisable to make them members of a standard usergroup and configure the usergroups role-membership later if you can envision to change the set of standard roles sooner or later.
Danial Mustofa Habibi
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 8:24 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hi All Thank's for your answer ..it' really help me a lot emoticon

Regards

Danial
Linus Sphinx
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 10:24 AM
Answer

Linus Sphinx

Rank: Junior Member

Posts: 89

Join Date: August 12, 2010

Recent Posts

I think you can set it in your portal-ext.properties like so:

# Input a list of default role names separated by \n characters that are associated with newly created users.
admin.default.role.names=Power User\nUser

Everyone created will have those roles by default, goes for all LDAP import users created too.
Hitoshi Ozawa
RE: automatic assign Roles to new Created User LIferay 6
April 13, 2012 7:56 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Yes, it's possible to set default roles in portal-ext.properties. In this case, however, you'll need to restart Liferay application server to make the setting effective.
Danial Mustofa Habibi
RE: automatic assign Roles to new Created User LIferay 6
April 21, 2012 6:27 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hitoshi Ozawa:
Yes, it's possible to set default roles in portal-ext.properties. In this case, however, you'll need to restart Liferay application server to make the setting effective.


Hi Hitoshi thank's for your answer..i"ve try it and it's work, if I'm using normal method to create user. using user registration page liferay or using control panel. But When I'm using my custom portlet(Which called liferay service util to create user ) it seem doesn't work and didn't automatic assign roles and user group. any idea why this is happen?or did I miss Something?

Regards

Danial
Hitoshi Ozawa
RE: automatic assign Roles to new Created User LIferay 6
April 21, 2012 7:15 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

If you using UserServiceLocalUtil, you're able to specify roles users. Have you tried adding with addUser(User)?
Danial Mustofa Habibi
RE: automatic assign Roles to new Created User LIferay 6
April 21, 2012 10:11 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hitoshi Ozawa:
If you using UserServiceLocalUtil, you're able to specify roles users. Have you tried adding with addUser(User)?


I'm using this method to add New User in my Costum Portlet
1UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext)

Does It different? with the method u provide? and example for default all created new user assigned to Penumpang Roles and UserGroups Penumpang..what service I should use?

Regards

Danial
Hitoshi Ozawa
RE: automatic assign Roles to new Created User LIferay 6
April 21, 2012 4:30 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I think this was what I did. Get default roles by using PropsUtil to get default roles name. Add the userGroupIds bases of these values.
Danial Mustofa Habibi
RE: automatic assign Roles to new Created User LIferay 6
April 21, 2012 4:44 PM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hitoshi Ozawa:
I think this was what I did. Get default roles by using PropsUtil to get default roles name. Add the userGroupIds bases of these values.



can you give some example?I'm a bit confuse....