RE: modify user roles through a button in the menu

Amos Fong, modified 6 Years ago. New Member Post: 1 Join Date: 4/9/19 Recent Posts
Is it possible to delete / reset the roles of a user using a button in the top navigation menu?

I have created a new entry in the menu control bar but I can not understand how I can assign the code that performs these functions to the button that appears.

I'm looking at liferay sources to create a fragment, but I do not know if I'm on the right track, since basically I do not know if what I want to do is possible through a single button.

​​​​​​​Thanks in advance!
thumbnail
Fernando Fernandez, modified 6 Years ago. Expert Posts: 401 Join Date: 8/22/07 Recent Posts
Hi Ivan,

Can you be more specific?
  • What version are you using? 
  • Where and how exactly have you created the new entry?
  • Will the user be able to reset her/his own roles? (does this make sense?) Or someone else's?
Maybe if you explain your use case we'll be able to help you better.

Cheers

Fernando
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Definitely provide more details as Fernando has asked, but I think the answer in the end will be a case of creating an MVCActionCommand class with the role changing logic you need. In that class you will be able to inject (@Reference) the Liferay services you need and in the action handler use them with whatever logic you require. 

On the UI side, you would use the <liferay-portlet:actionURL/> to create the action url linked to your command. The reason I offer the <liferay-portlet:actionURL/> in place of the <portlet:actionURL/> is becuase the extended (liferay) version gives you a few extra tag attributes that are handy. With it you can specify the portletName (for the portlat that the MVCActionCommand is associated with) and a plid for cases where the portlet you are targeting is not the portlet rendering the button, and where it lives on another page. 
​​​​​​​