Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Liferay 7 customize Edit User page
I have requirements to customize the Edit User page as the client wants to do the following:
- add more Prefix choices
- remove Suffix field
- have predefined Job Title (dropdown style)
Is there a way to edit the existing Edit User page to do these? I've read that there's a need to edit the database in order to achieve it. Also, most solutions I found in this forum refer to older Liferay and I can't apply to Liferay 7.
Jason Chee:I have requirements to customize the Edit User page as the client wants to do the following:
- add more Prefix choices
- remove Suffix field
- have predefined Job Title (dropdown style)
Two of those requirements are theoretically achievable by modifying global language keys for all of the languages you wish to support in your Liferay instance.
- To add more prefix choices, update the
lang.user.name.prefix.values value in
Language*.propertiesto include the new prefixes. - To remove the suffix field, update the
lang.user.name.field.names value in
Language*.propertiesto not includesuffix.
The last requirement will require an actual code-level customization.
- If you want the job title to be a select box rather than a text
input field, you will need to customize details.jsp
in
com.liferay.users.admin.webandcom.liferay.my.account.web(when rebuilding from source, you only need to change one file because they're copied as part of the build process, but when customizing Liferay, you need to change it in both places).
Hi Minhchau, thanks for your response!
However, I'm not able to find the files you mentioned. My folder structure is like below:

I can't seem to locate the files you mentioned. I feel like there's something really simple that I am missing!
Jason Chee:However, I'm not able to find the files you mentioned.
The files are buried inside of zip files in a regular bundle, and normally people use the extension points described in the online documentation to make it easier to comply with Liferay's open source license agreement, which means you don't actually need to know where the file actually is in your bundle (just a general idea of what you need to do for customization is sufficient).
If, out of curiosity, you want to see the actual code that is used with your version of Liferay:
-
Language*.propertiesare inside of thecontentfolder oftomcat-8.0.32/webapps/ROOT/WEB-INF/lib/portal.impl.jar -
details.jspare inside of theMETA-INF/resources/userfolder ofcom.liferay.users.admin.web-[VERSION].jarinside of theosgi/marketplace/Liferay Foundation.lpkg
Hi again Minhchau, sorry for the late response. I've been trying to do this but still not getting it. I manage to do it by replacing the portal.impl.jar, however I want to do it the right way following your tutorial.
Help me understand the following
"Once you know the keys to override, create a language
properties file for the locale you want (or the
default Language.properties file) in your
module’s src/main/resources/content folder. In your file,
define the keys your way. For example, you could override the publish key."
Currently I only have a theme deployed. I don't have any module. When
the above instruction mentions "in your
module’s src/main/resources/content folder", where
would that be?
Jason Chee:Currently I only have a theme deployed. I don't have any module. When the above instruction mentions "in your module’s
src/main/resources/contentfolder", where would that be?
The tutorial assumes you know how to create a new OSGi module,
following the instructions on Creating
Projects with Blade CLI, and that would have a
src/main/resources folder that you could add a
content folder to.
I use Liferay IDE and I have tried creating modules before. However, in the context of making global changes to the Language.properties, what kind of module am I suppose to create?
Jason Chee:I use Liferay IDE and I have tried creating modules before. However, in the context of making global changes to the Language.properties, what kind of module am I suppose to create?
Since the tutorial has you create everything without relying on any boiler plate code being auto-generated for you, it shouldn't matter.
Minhchau Dang:Two of those requirements are theoretically achievable by modifying global language keys for all of the languages you wish to support in your Liferay instance.
- To add more prefix choices, update the lang.user.name.prefix.values value in
Language*.propertiesto include the new prefixes.- To remove the suffix field, update the lang.user.name.field.names value in
Language*.propertiesto not includesuffix.The last requirement will require an actual code-level customization.
- If you want the job title to be a select box rather than a text input field, you will need to customize details.jsp in
com.liferay.users.admin.webandcom.liferay.my.account.web(when rebuilding from source, you only need to change one file because they're copied as part of the build process, but when customizing Liferay, you need to change it in both places).
Hey Minhchau, following the "modifying global language
keys" tutorial, I can change the text of sign-in.
However changes made to lang.user.name.prefix.values
and lang.user.name.suffix.values don't work. Any idea
what's the difference?
Jason Chee:I can change the text of
sign-in. However changes made tolang.user.name.prefix.valuesandlang.user.name.suffix.valuesdon't work. Any idea what's the difference?
Do you have your code available anywhere? I started a build of 7.0.x
and followed the tutorial, and modifying
lang.user.name.prefix.values and
lang.user.name.suffix.values worked just fine.
With that being said, I was mistaken on how
lang.user.name.field.names works, since it only removes
the field from being considered when generating full names but
leaves the field on the page. This means that you would need to
modify details.jsp for that one as well.
Edit: Never mind, I was actually right the first time about
lang.user.name.field.names influencing fields on the
details page. It just needed a server restart, since it looks like it
only is able to do the replacement once. I'm guessing that's what you
need as well.
These are my codes, of which only the edited value
of sign-in shows.
Language.properties:
lang.user.initials.field.names=first-name lang.user.name.field.names=prefix,first-name lang.user.name.prefix.values=Prefix A, Prefix B sign-in=Test Value
CustomLanguage.java:
package custom.language;
import java.util.Enumeration;
import java.util.ResourceBundle;
import org.osgi.service.component.annotations.Component;
import com.liferay.portal.kernel.language.UTF8Control;
@Component(
property = { "language.id=en_US" },
service = ResourceBundle.class
)
public class CustomLanguage extends ResourceBundle {
private final ResourceBundle resource = ResourceBundle.getBundle(
"content.Language", UTF8Control.INSTANCE);
@Override
public Enumeration<String> getKeys() {
return resource.getKeys();
}
@Override
protected Object handleGetObject(String key) {
return resource.getObject(key);
}
}
My module in Liferay workspace:

I'm not sure what happened but the changes have reflected all of a sudden after multiple times of redeploying. I just tried changing the list of prefixes once more and yet again, the changes don't reflect while changes to other keys such as first-name reflect immediately. Tried clearing cache and no luck as well. Seems like some changes are immediate while others are not?
Strange, but problem kinda solved I guess! Thanks for your time MinhChau.