- JavaScript 92.3%
- Go Template 4.8%
- SCSS 2.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| docs | ||
| languages | ||
| lib | ||
| presets | ||
| public | ||
| scss | ||
| templates/admin/plugins | ||
| test | ||
| .gitignore | ||
| CHANGELOG.md | ||
| eslint.config.mjs | ||
| library.js | ||
| LICENSE | ||
| package.json | ||
| plugin.json | ||
| README.md | ||
| SECURITY.md | ||
nodebb-plugin-rank-badges
Rank badges for NodeBB 4. Members earn ranks from their post count, their reputation or both, and members of selected groups (administrators, moderators or any group you choose) get a group badge instead. The badge sits next to the author's name in every post and on the profile page, in the viewer's language, and everything is configured in the ACP — no template edits needed.
Quick start
cd /path/to/nodebb
npm install nodebb-plugin-rank-badges
./nodebb activate nodebb-plugin-rank-badges
./nodebb build && ./nodebb restart
Then open ACP → Plugins → Rank badges. The default six-level ladder works out of the box; adjust names, thresholds, images and colours to suit your community.
- Requirements: NodeBB
^4.0.0(tested with 4.16 and the Harmony theme), Node.js 22+. - Author: nairda · Issues: GitHub
Features
- Ranks with thresholds for posts and reputation. Modes: posts and reputation (default), posts only, reputation only, either one. The user gets the highest rank in the list they qualify for.
- Group badges for any group; a group badge wins over the rank. Category moderators can share the "Global Moderators" badge.
- Names per language typed in the ACP, or translations from the plugin's language files (en-GB, pl; other languages fall back to en-GB) for the default ranks.
- Viewer's language everywhere: full page loads, ajaxify navigation, infinite scroll, new replies arriving over the websocket and API responses.
- Level bar (one segment per rank, or "3/12" for ladders longer than 10 ranks) and an optional image per rank or group. If an image fails to load, the level bar, the group icon or a generic icon is shown instead.
- Accessible: the visible name always carries the meaning (colour is only an accent),
aria-label"Rank 3 of 6: Tinkerer", readable contrast in light and dark mode (group badges pick black or white text for their colour),forced-colorssupport. - Fast: settings and rendered badges are cached in memory; group membership is checked once per group for all authors on a page (no extra queries per post).
- Themeable: every colour and size is a CSS custom property.
- ACP in English and Polish, with validation, warnings and a preview of the saved badges.
- Translations for badge names: en-GB and pl included; other languages fall back to en-GB.
Default ladder (change everything in the ACP):
| Level | en-GB | pl | Posts | Reputation |
|---|---|---|---|---|
| 1 | New at the bench | Nowy na warsztacie | 0 | 0 |
| 2 | Apprentice | Praktykant | 5 | 0 |
| 3 | Tinkerer | Majsterkowicz | 25 | 5 |
| 4 | Technician | Technik | 75 | 20 |
| 5 | Engineer | Inżynier | 200 | 50 |
| 6 | Builder | Konstruktor | 500 | 150 |
| – | Administrator | Administrator | group administrators |
|
| – | Moderator | Moderator | group Global Moderators |
Installation
Install from the command line (see Quick start) or in ACP → Extend → Plugins, then rebuild and restart NodeBB. NodeBB 3.x and older are not supported.
Configuration
ACP → Plugins → Rank badges
- How ranks are earned — the mode, see How ranks are computed.
- Languages for rank names — which name columns to show (e.g.
en-GB, pl, de). An empty name falls back to the plugin's translation (default ranks), to the first name given, and finally to "Rank N". Names in languages removed from this list are deleted when you save. - Ranks — order matters (level = position). Thresholds are whole numbers written with digits
(
1e3,2.5or-1are refused). Every rank needs a name in at least one language (or a key from the language files, as the default ranks have). Image: upload (PNG, JPG, WebP, GIF or SVG up to 512 KB, stored inuploads/rank-badges/under a unique name) or a URL starting with/orhttps://; square, at least 64 px. Colour:#rrggbb, used as an accent. - Group badges — group name exactly as in ACP → Groups, name, Font Awesome icon (
fa-shield-halved), image, colour, "Show if hidden" (see below). - Add badge to posts automatically — uses the
custom_profile_infoslot that Harmony and Persona render next to the author name. Turn it off if your theme prints the badge itself. - Restore defaults — puts the default ranks and group badges back into the tables (saved only when you click Save).
- Presets — see Presets.
Saving shows a confirmation or the error. The settings are validated in the browser and again on the server; invalid settings are not stored. If the ACP cannot read the stored settings, saving is disabled so that the defaults shown in the form cannot overwrite them. Under the tables the ACP lists warnings that do not block saving: ranks out of order, ranks with the same thresholds, ranks that can never be reached, an empty rank list, groups that do not exist or are hidden.
How ranks are computed
-
Ranks are checked in list order and the user gets the last rank whose thresholds they meet, so keep the thresholds ascending (the ACP warns otherwise).
-
Level 1 is the starting rank. If its counted thresholds are 0, every user has it, whatever their post count or reputation (also negative).
-
For every other rank a threshold of 0 means "no requirement" for that criterion and never grants the rank by itself. The rank is reached through its non-zero counted thresholds:
- posts and reputation: all non-zero thresholds must be met;
- posts only / reputation only: the non-zero posts / reputation threshold must be met;
- either one: one non-zero threshold is enough.
A rank after the first whose counted thresholds are all 0 can never be reached. Example: with the default ladder in reputation only mode, level 2 (5 posts, 0 reputation) is skipped and users go from level 1 straight to level 3 at 5 reputation.
-
Reputation disabled (ACP → Settings → Reputation): every mode counts posts only, in posts and on profiles alike. The ACP shows a note about it.
-
An empty rank list means no rank badges at all (group badges still work). The default ladder is used only until the settings are saved for the first time.
Group badges
- Precedence, independent of the order of the user's memberships:
administrators;Global Moderators— including category moderators when "Category moderators get the Global Moderators badge" is on (and aGlobal Moderatorsentry exists);- every other group, in the order of the ACP list.
- Hidden groups: NodeBB does not show membership of hidden groups, and neither does this plugin: a
badge for a hidden group is not shown unless its "Show if hidden" box is ticked (off by default).
Even then the group name is kept out of the markup (
data-group) and of the API data (groupis empty), and a badge without a name of its own is called "Team". Private groups (join by approval) are shown normally: their membership is public in NodeBB, andGlobal Moderatorsis a private group. - Groups that do not exist are skipped, and the ACP warns about them. A group badge is tied to a group name: if a configured group is deleted or renamed, or its name is misspelt, anyone allowed to create groups can create a group with that name and give its members the badge. Keep the "Create groups" privilege for trusted users, and fix or remove entries the ACP reports as missing.
- Existence and the hidden flag are re-read at least every minute and whenever the settings are saved.
Presets
A preset is a folder presets/<id>/ with a preset.json and image files; every such folder whose
name uses only a-z, 0-9 and - gets a "Load preset" button in the ACP. Loading fills the tables;
nothing changes until you click Save. Image entries must be plain file names in that folder with an
image extension (rank-1.png, no sub-folders or ..); others are skipped. Format:
presets/README.md.
The folder lives inside the plugin, so a preset you add yourself is removed when the plugin is updated
or reinstalled: keep a copy. The npm package ships no preset; the wirelab preset is available only in
the GitHub repository (see Licence).
Preset files are served as static files from the forum's origin
(/assets/plugins/nodebb-plugin-rank-badges/presets/…), without the protective headers NodeBB adds to
user uploads. Badges always show them through <img>, where SVG scripts do not run, but a script in an
SVG opened directly would run on the forum domain: put only SVG files you trust in presets/.
For theme authors
Post data (filter:posts.getUserInfoForPosts) gets user.rankBadge:
{ level: 3, total: 6, tier: 2, special: false, key: 'rank-3', group: '', image: '', color: '', name: 'Tinkerer', html: '<span class="rank-badge …">…</span>' }
In a template: {{{ if posts.user.rankBadge }}}{{posts.user.rankBadge.html}}{{{ end }}}.
Encoding:
htmlis ready-made markup, already translated. Everything typed in the ACP is stored as plain text and HTML-escaped when the badge is rendered, with[and]written as[/], so names can never become NodeBB translation tokens, even if the markup is translated again.nameis HTML (escaped the same way), in the viewer's language.groupis the raw group name, empty for hidden groups — escape it before printing it yourself.- Settings read directly with
meta.settings.get('rank-badges')are not escaped.
When you print the badge yourself, skip custom_profile_info entries with rankBadge: true (or turn
off automatic insertion). Profiles get rankBadge in the account data; the plugin's client script puts
it in [component="user/badges"] (Harmony account header). Search results and the post lists on
profiles use NodeBB's post summaries, which carry no badge.
Badge attributes: data-rb (r2 = third rank, s0 = first group entry), data-rb-lang (language
of the markup), data-level / data-total (ranks), data-group (groups that are not hidden).
Styling — override the variables, not the selectors:
:root {
--rank-badge-height: 1.5rem;
--rank-badge-radius: .45rem;
--rank-badge-font-size: .78rem;
--rank-badge-image-size: 1.25rem;
--rank-badge-tier-1-bg: …; --rank-badge-tier-1-fg: …; --rank-badge-tier-1-led: …; /* low levels */
--rank-badge-tier-2-bg: …; --rank-badge-tier-2-fg: …; --rank-badge-tier-2-led: …; /* middle */
--rank-badge-tier-3-bg: …; --rank-badge-tier-3-fg: …; --rank-badge-tier-3-led: …; /* top */
--rank-badge-special-bg: …; --rank-badge-special-fg: …; /* groups */
--rank-badge-led-off: …;
}
.rank-badge--special[data-group="Global Moderators"] { --_bg: …; --_fg: …; }
A group colour set as var(--…) cannot be evaluated on the server; its text stays white unless you
set --rank-badge-accent-fg.
Supplying a level from another plugin
Another plugin can decide a user's rank level (for example a combined score from a different system)
with the filter:rank-badges.level hook. The hook receives { uids, users, levels }; a listener sets
levels[uid] to an integer, where 1 is the lowest rank:
plugins.hooks.register('my-plugin', {
hook: 'filter:rank-badges.level',
method: async (data) => {
data.uids.forEach((uid) => { data.levels[uid] = lookupLevel(uid); });
return data;
},
});
- The level replaces the post/reputation rank for that user, on posts and on profiles. Values above the number of ranks are clamped to the highest rank; anything that is not an integer ≥ 1 is ignored.
- Group badges keep precedence (administrators, moderators and your own groups are shown as before).
- Users without an entry keep their normal rank. If a listener throws, a warning is logged and every user keeps the normal rank, so a faulty listener cannot hide badges.
- The hook runs once per request for all users of the page, so read your data in one batch
(for example
User.getUsersFields) rather than one query per user.
Read-only API
GET /api/v3/plugins/rank-badges/ladder?lang=en-GB returns the effective mode, the ranks (id,
level, thresholds, name, html, view) and the group badges that can appear on posts (id,
name, html, view, without the group name), in the requested language (default: the viewer's).
view is the same badge as plain data (classes, data attributes, colour, image, icon, bar, plain-text
name and label); the plugin's scripts build badges from it with DOM methods (lib/badge-dom.js)
instead of inserting HTML. The route answers 403 when the viewer cannot read any category, e.g.
guests on a forum closed to guests, and 429 after 300 requests per minute from one user or IP
address. The plugin's client script uses it to translate badges of posts that arrive over the
websocket.
External images get referrerpolicy="no-referrer" and loading="lazy", so the image host does not
learn which topic is being read; it still sees the viewer's IP address, so prefer uploaded images.
Security
Review and scanning. Every release runs the unit tests and the linter. In October 2026 the code went through an independent code review and a Snyk Code scan; all reported issues were fixed, and the scan showed no open findings at that time. This is a point-in-time result, not a guarantee. Please report vulnerabilities privately — see SECURITY.md.
Update notices
Once a day the plugin asks updates.wirelab.pl whether a newer version exists, and shows "Version X is available — what's new" on its ACP page when it does.
- What is sent: nothing beyond a plain
GET https://updates.wirelab.pl/api/nodebb-plugin-rank-badges.json. No query string, no cookies, no forum URL, user or usage data. TheUser-Agentheader isnodebb-plugin-rank-badges/<installed version>. As with any web request, the server (GitHub Pages) sees the forum server's IP address. - How often: at most once a day, in the background and when the ACP page is opened (from a cache kept in the database). 5 s timeout; network errors are logged at verbose level only.
- Switching it off: ACP → Plugins → this plugin → "Check for updates". When it is off, no request is made at all.
Development
npm install
npm test # node:test — thresholds, precedence, validation, escaping, rendering, language, cache
npm run lint
lib/ holds the logic without NodeBB dependencies (ranks.js, render.js, lang.js, lru.js);
library.js wires it into NodeBB hooks.


