Deleting the user and Changing the status : Active and Deactive of the user
Here is the following code to delete the user and change the status of the user
In Liferay After deactivating the user then only we can delete the user.
It is the below code what liferay is using to delete and update the status of the user.
protected void deleteUsers(ActionRequest actionRequest) throws Exception {
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
//Getting the List of all the Users
long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);
// Based on the user status selected we are changing the status
for (long deleteUserId : deleteUserIds) {
if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {
int status = WorkflowConstants.STATUS_APPROVED;
if (cmd.equals(Constants.DEACTIVATE)) {
status = WorkflowConstants.STATUS_INACTIVE;
}
UserLocalServiceUtil.updateStatus(deleteUserId, status); // Updating the Status
}
else {
UserLocalServiceUtil.deleteUser(deleteUserId); // Deleting the Status.
}
}
}
Comments
Post a Comment