Reputation: 1985
I have two sites (site1
and site2
) and two groups (group1
and group2
). I have Sign In
Liferay's portlet on both sites. I want that If user registers by Sign In
portlet on site1
then user is assigned to group1
and if user registers by Sign In
portlet on site2
then user is assigned to group2
.
How to do it?
===EDIT===
I tried write hook with struts action but it does not work for me.
liferay-hook.xml:
<hook>
<struts-action>
<struts-action-path>/login/create_account</struts-action-path>
<struts-action-impl>com.mypackage.CreateAccountAction</struts-action-impl>
</struts-action>
</hook>
CreateAccountAction.java:
package com.mypackage;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import com.liferay.portal.kernel.struts.BaseStrutsPortletAction;
import com.liferay.portal.kernel.struts.StrutsPortletAction;
public class CreateAccountAction extends BaseStrutsPortletAction {
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
System.out.println("CreateAccountAction");
originalStrutsPortletAction.processAction(originalStrutsPortletAction,
portletConfig, actionRequest, actionResponse);
}
}
Click on Create Account cases:
12:25:38,177 ERROR [http-bio-8078-exec-126][PortletRequestProcessor:466] Forward does not exist
Upvotes: 1
Views: 520
Reputation: 4210
You may write hook to override struts-action(/login/create_account
) responsible for creating account. Overriding and Adding Struts Actions
In code, perform Original struts action's processAction (com.liferay.portlet.login.action.CreateAccountAction
), after that check for SessionErrors
object, it should be empty.(Because then only user will have been created)
If SessionErrors
is empty, then get User object by emailaddress(get emailaddress from request parameter) and current group from themeDisplay
object.
Having User object and current group object you can easily assign user to group by GroupLocalServiceUtil.addUserGroups(userId, groupId)
Upvotes: 1