Hippo CMS控制台创建用户:自定义属性配置求助
Got it, let's work through adding those custom user attributes in Hippo CMS—this is a super common customization once you need to go beyond the default fields, so I’ll walk you through every step clearly.
1. Define a Custom User Node Type
Hippo stores user data as JCR nodes, with the default user type being hipposys:user. We’ll create a custom node type that inherits from this base type, then add your project-specific properties (phone number, city, user type).
- Create a new CND (Content Node Definition) file (e.g.,
custom-user.cnd) in your project’srepository-data/configuration/nodetypesdirectory. - Add this content to define your custom type and properties—replace the namespace with your project’s unique one:
<custom = 'http://your-project-domain.com/custom/nt/1.0'> [custom:user] > hipposys:user orderable - custom:phoneNumber (string) // Stores phone number - custom:city (string) // Stores user's city - custom:userType (string) < 'admin', 'editor', 'viewer' // Enforce allowed user types - Deploy this change—Hippo will recognize the new node type when the repository starts up.
2. Update the Console User Edit Form
Next, we need to make these custom fields visible in the CMS console’s user creation/edit interface.
- Navigate to your CMS webapp’s configuration folder, usually
src/main/resources/META-INF/hst-assembly/overrides. - Create or edit
org.hippoecm.frontend.plugins.cms.admin.users.UserEditorPlugin.propertiesto add your fields to the form:# List fields in the order you want them to appear fields=hipposys:username,hipposys:password,hipposys:passwordConfirm,custom:phoneNumber,custom:city,custom:userType # Add human-readable labels for each custom field custom:phoneNumber.label=Phone Number custom:city.label=City custom:userType.label=User Type - Optional: Add validation rules (like requiring a phone number) by creating a
UserEditorPluginValidation.xmlfile in the same directory:<validations> <validation property="custom:phoneNumber"> <validator name="required"/> <validator name="regexp"> <param name="regexp">^\+?[0-9\s\-]+$</param> <param name="message">Please enter a valid phone number (e.g., +1 555-123-4567)</param> </validator> </validation> </validations>
3. Set Permissions for Custom Properties
Make sure console users have the right access to read and write these new attributes.
- Update your repository’s security config (either via the Console’s Security section or
repository-data/configuration/security/usersfiles) to grantreadandwritepermissions forcustom:*properties to roles likecms-admin.
4. Test the Customization
- Restart your Hippo CMS instance.
- Head to the CMS Console > Users & Groups > Create User. You should see your custom fields alongside the default username/password fields.
- Fill out the form and save, then verify the data is stored correctly: Use the Console’s JCR Explorer to check
/hipposys/users/[your-new-user]—you’ll see the custom properties listed there.
Optional: Index Custom Attributes (For Search)
If you need to search users by phone number, city, or user type, update the search index config:
- Edit
repository-data/configuration/indexes/hipposys/index-definition.xmland add your custom properties to the user index:<indexes> <index name="users"> <nodeType>hipposys:user</nodeType> <property name="custom:phoneNumber" type="string"/> <property name="custom:city" type="string"/> <property name="custom:userType" type="string"/> </index> </indexes>
That’s all! You should now be able to manage your project-specific user attributes without relying on Hippo’s default fields.
内容的提问来源于stack exchange,提问作者Gaurav Mulay

