Hidden User Fields for Discourse
⚠️ Disclaimer: The author assumes no liability for data exposure or unintended visibility of user fields. Test thoroughly before production use.
A Discourse theme component that controls visibility of custom user fields based on group membership. Hide sensitive or internal user fields from public view while making them visible to specific groups.
- Group-Based Visibility: Control which groups can see which custom user fields
- Multiple Rules: Configure multiple field/group combinations
- User Card & Profile: Works on both user cards (hover) and full profile pages
- Native Display: Uses Discourse's native field styling
- Easy Configuration: Object editor with group picker for managing visibility rules
- Go to your Discourse admin panel
- Navigate to Customize > Themes
- Click Install > From a git repository
- Enter:
https://github.com/dereklputnam/discourse-hidden-user-fields - Click Install
- Download or clone this repository
- Zip the entire directory
- Go to Customize > Themes in Discourse admin
- Click Install > From a file
- Upload the zip file
After installation, configure visibility rules:
- Click on the installed theme
- Go to Settings
- Edit field_visibility_rules using the object editor
- For each rule:
- Click Add Field
- Enter the Field Name (exact name of your custom user field)
- Use the Allowed Groups picker to select one or more groups
- Click the checkmark to save
Example:
- Field Name:
company - Allowed Groups: Select
employeesfrom the group picker
Users in ANY of the selected groups will be able to see the field.
- Custom user fields must be created in Admin > Customize > User Fields
- Groups must exist for the visibility rules to work
- Users must be members of the specified groups to see the fields
discourse-hidden-user-fields/
├── about.json # Theme metadata
├── settings.yml # Theme settings schema
├── common/
│ └── common.scss # Minimal CSS placeholder
└── javascripts/discourse/initializers/
└── custom-field-visibility.js # Main logic
- On page load, the initializer reads your visibility rules
- For each rule, it finds the corresponding custom field by name
- Hide CSS is injected once per field to hide it from everyone by default
- For each rule, if the current user is in any of the allowed groups, show CSS is injected for that specific field
- Fields are only visible when the user has permission via group membership
MIT