
LeanRoles – User Tags & Role Performance Audit
v0.7.0David Marín Carreño (DaveFX) · 2026年8月25日 上架
Audits what your user roles cost on every request, and adds user tags: label users without creating roles that grant nothing and weigh nothing.
- 正在使用
- 10 以下
- 评分
- 暂无
- 累计下载
- 631
- 最近更新
- 2026年11月22日
截图






WordPress keeps every role in one autoloaded option, with each role’s capabilities copied out in full, because core has no inheritance. On a membership or commerce site with forty roles that option is read, unserialized and held in memory by every PHP worker on every request — and those are exactly the sites whose traffic is mostly logged in, so page caching never gets a look in.
LeanRoles does two things about it.
It measures. The auditor is strictly read-only. It takes the size of your role option with LENGTH() in the database rather than re-serializing it in PHP, times a real unserialize() of it on your machine after a warm-up pass, measures the resident footprint with the result kept alive, and works out what that costs in concurrent workers. It identifies roles that grant no effective permission, roles nobody holds, roles with identical capability sets, and capabilities it cannot account for — while being explicit that “unrecognised” is not “orphaned”, because custom code checks capabilities no scanner can see.
It offers the missing primitive. There is no way in WordPress to say “this user is a wholesale customer” without granting them permissions. There are only roles. That is why membership plugins keep inventing them: they have no alternative. A LeanRoles tag is that alternative. It appears in $user->roles, answers current_user_can(), and can be filtered on in WP_User_Query — and it is never written to the autoloaded option. Third-party code cannot tell the difference.
What it does
- The auditor, with real measurements and
wp leanroles audit --format=json - User tags: create, assign individually or in bulk, filter, a users-list column, CSV import and export
- The tag engine as a standalone library,
libraries/user-tags/, that any plugin can bundle so tags cost them nothing to adopt - WP-CLI: create a tag, assign it in bulk by role, edit or delete a role with reassignment, move a role configuration between sites, take and restore role-option backups
Licensing
LeanRoles uses Freemius for licensing, payment and automatic updates on its paid plan. Freemius is a third-party service. It is one of the two external services the plugin uses, both listed under External services below.
Nothing is sent anywhere unless you say so: by opting in, by activating a licence, or by submitting the deactivation survey described below. The plugin asks to opt in once, on activation, and skipping is a real option: skip it and the plugin works exactly as it does otherwise. Nothing about the auditor or user tags depends on it.
If you do opt in, what is shared is:
- your WordPress user’s name and email address;
- the site’s homepage URL and title, its language, and the WordPress and PHP versions;
- which version of LeanRoles is running, its SDK version, and whether it is active, deactivated or uninstalled;
- the list of other plugins and themes installed on the site (names, slugs, versions, and whether each is active). This one is a separate, optional permission on the opt-in screen. In the free version it comes ticked, so untick it if you do not want it sent. When you activate a licence it starts unticked.
No newsletter subscription is requested.
Activating a licence key sends the key and the site URL, so the licence can be checked and updates delivered to you.
The deactivation survey. Deactivating the plugin shows a short “why are you leaving?” survey. Your answer is stored on the site and sent only when the plugin is deleted:
- If you skip the survey, nothing is sent.
- If you never opted in and tick “Anonymous feedback”, only the reason you chose, up to 128 characters of any text you typed, and an anonymous site identifier are sent.
- If you never opted in and submit it without ticking that box, the plugin opts you in at that moment and sends everything listed above for opting in, along with your answer.
- If you had opted in, your answer goes along with the uninstall notice.
Freemius’ terms and privacy policy cover what they do with it.
What the paid plans cost, and what they add
What it does not do
It does not convert roles into tags for you. What it gives you are three independent primitives — create a tag, assign it in bulk, delete a role with reassignment — which compose into a conversion done by hand, by someone who has read the audit and accepts the risk.
Before deleting a role it tells you how many capabilities that role grants and how many users hold it. It does not tell you which of those users will actually notice the difference: answering that means computing effective capabilities per user, before and after, and the plugin does not do it. Take a backup and check for yourself.
External services
LeanRoles works without any external service. Two are used, and only when somebody asks for them:
- Freemius, for licensing and the paid plans. It is contacted only if you opt in on activation, activate a licence, or answer the deactivation survey and later delete the plugin. What it receives in each case is set out under Licensing above. Terms, privacy policy.
- The “More plugins” tab of the audit screen lists the author’s other plugins. When an administrator opens that tab, the plugin downloads the list from
https://davefx.com/plugins.json, at most once a week (every twelve hours while it cannot be reached, showing a copy bundled with the plugin meanwhile). Nothing about the site’s users or its roles is sent, and the request does not name the site: it identifies itself only as the library that makes it. As with any web request, davefx.com’s server receives the IP address of the server making it. Nothing is downloaded until the tab is opened. Privacy policy.
Development
The distributed plugin has no dependencies and no build step: what is in src/ and assets/ is what runs. Composer is used only for the test suite, and .distignore keeps all of it out of the release.
composer install
./tests/bin/start-db.sh # throwaway MariaDB on 127.0.0.1:3307
./tests/bin/install.sh # WordPress + the test library
composer test # single site
composer test:multisite # network
composer test:matrix # WordPress 5.9, 6.5 and latest
composer lint # standards + PHP 7.4 compatibility
Every test runs against a real WordPress install and a real database, because the risky parts of this plugin are all seams it does not own — the short-circuit contract of the metadata filters, what WP_User::set_role() does on its way past, how WP_User_Query builds a role clause. See tests/README.md.