Add the user details in Programatically.
=============================
ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
User user = null;
=============================
ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
User user = null;
String emailaddress = ParamUtil.getString(“emailaddress”);
String screenName = ParamUtil. getString(“screenname”);
List<User> users = UserLocalServiceUtil.getUsers(0,
UserLocalServiceUtil.getUsersCount());
for(User user : users) {
if(emailAddress.equalsIgnoreCase(user.getEmailAddress())
|| screenName.equalsIgnoreCase(user.getScreenName())){
System.out.println(“user is already
exists ”);
}
else{
}
}
long[] groupIds = {themeDisplay.getLayout().getGroupId()};
ServiceContext serviceContext =
ServiceContextFactory.getInstance(User.class.getName(), req);
serviceContext.setScopeGroupId(themeDisplay.getLayout().getGroupId());
long[] roleIds = {};
long[] organisationIds = {};
long[] userGroupIds = {};
user
=UserLocalServiceUtil.addUser(20199, themeDisplay.getCompanyId(), true, "", "", false, screenNam, emailAddrs,facebookId, "", Locale.ENGLISH, firstName, "", lastNameUsr, 1, 1, true, 10, 10, 1900, "", groupIds, roleIds, organisationIds, userGroupIds, true, serviceContext);
Get the current user login details:
=============================
User user = null;
ThemeDisplay themeDisplay = (ThemeDisplay)
req.getAttribute(WebKeys.THEME_DISPLAY);
user = themeDisplay.getUser();
long curLoginUserid = user.getUserId();
Update the current user login details:
===========================
String email = UpdateForm.getEmailAddress();
String updateScreenName = UpdateForm.getScreenName();
String updateFstName = UpdateForm.getFisrtName();
String updateLastName = UpdateForm.getLastName();
String updateCompanyName = UpdateForm.getCompanyName();
ThemeDisplay themeDisplay = (ThemeDisplay)
req.getAttribute(WebKeys.THEME_DISPLAY);
User loginUser = themeDisplay.getUser();
loginUser.setEmailAddress(email);
loginUser.setUserId(userId);
loginUser.setFirstName(updateFstName);
loginUser.setLastName(updateLastName);
loginUser.setScreenName(updateScreenName);
UserLocalServiceUtil.updateUser(loginUser);
No comments:
Post a Comment