Three ways an account gains administrator power, and the plugin records which one happened.
meta.path | What it is |
|---|---|
role_api | WP_User::set_role() / add_role() — the normal admin-UI route |
user_register | An account created straight into a privileged role |
direct_meta | A raw update_user_meta( $id, 'wp_capabilities', … ) that added privilege |
Why direct_meta is the interesting one
Nothing in WordPress core promotes a user that way.
Writing the capabilities map directly, without going through the role API, is the classic post-exploitation backdoor: a compromised plugin or an injected payload grants itself administrator without firing any of the actions a monitoring plugin would be listening for.
It is the highest-signal detection in the plugin. On a healthy site it should never fire.
Two rules keep it quiet enough to be worth alerting on
A detection that cries wolf gets muted, and a muted detection is worse than none.
1. Diffed against the map stored before the write. Only *newly granted* capability keys count.
WP_User::add_cap() and remove_cap() rewrite the entire capabilities map and fire no role action. So a membership or LMS plugin calling add_cap() on an administrator rewrites 'administrator' => true — which read as a backdoor until the diff went in. It was not one; it was a plugin doing something ordinary.
2. Only the administrator slug is privileged, plus whatever itxuo_privileged_roles adds.
Matching by capability instead swept in WooCommerce's shop_manager and warned about ordinary store staff every time somebody was hired. The capability view survives as event meta — useful context when you are reading a real event — but never as the trigger.
Extending it
add_filter( 'itxuo_privileged_roles', function ( $roles ) {
$roles[] = 'site_manager';
return $roles;
} );
Worth doing if you have a custom role that is administrator in all but name.
Alerting on it
These events carry a high severity and are exactly what Alerts is for. A direct_meta promotion at 3am is the one notification worth waking up for.
What it does not do
It watches and records. It does not block — reverting a promotion automatically would be a plugin fighting your site over who is an administrator, and it would lose in ways that are hard to debug.