Audit admins and remove stale or rogue administrators

UsersAdvanced~15 min

Before you start

A connected site whose bound user holds the list-users, promote-users, and delete-users capabilities, with the get-users, get-user, update-user, and delete-user abilities enabled. delete-user is off by default. Take a database backup before you delete anyone.

The administrator list on a site that has been around a while collects ghosts: a contractor from two years ago, a plugin’s demo account, a login nobody can place. Every one of them is a full key to the site. This has the agent lay them all out with context so you can decide who keeps access, and it will not remove a single one until you say so.

The prompt
Help me audit who has administrator access on this site, and don't change a
single account until I approve it.
First pass, read only: list every user with the administrator role and, for
each one, pull their details, when they registered, and how much content they
own. Hand me a table with a short note on which ones look stale or unfamiliar,
the accounts nobody recognizes or that haven't done anything in ages.
I'll tell you what to do with each. For the ones I want to keep but downgrade,
lower their role. For the ones I want gone, delete them and reassign whatever
content they own to [me / a named editor]. Do the safe downgrades first, then
the deletions, a few at a time, and pause before each deletion to confirm.
You can't delete me or the last administrator standing, so there's a floor
under this no matter what I ask. When you're finished, list every account you
downgraded or removed and where their content went.

Why this is safe to run

The whole first pass is reads, so you get the full roster with context before anything happens to an account. Reading users, downgrading a role, and deleting a user are separate abilities with separate switches, so “don’t change anything” is enforced by the plugin, not just trusted: if you never enabled delete-user, the agent cannot remove an account even on request. The plugin refuses to delete the account the agent is acting as, or the last administrator, so you cannot lock yourself out. Downgrading a role is reversible and gets done first; deleting is permanent, so the flow reassigns each removed account’s content to a user you name and pauses for a yes before every deletion. Every step lands in the Activity Log.

Already connected? Skip the paste. Ask your agent for the “audit stale administrators” recipe and it runs the same read-first, approve-each flow across your own admin list.

How it works

  1. List every user holding the administrator role.
  2. Read each one's details, registration date, and how much content they own.
  3. Return a table flagging which accounts look stale or unfamiliar.
  4. Wait for you to say which to downgrade and which to remove.
  5. Do the downgrades first, then the deletions one at a time, pausing before each.
  6. Report every account changed and where its content was reassigned.

Questions

Could this lock me out of my own site?
No. The plugin never lets an account delete itself or remove the last administrator, so there is always a floor under an audit no matter what you ask. Deleting a user also reassigns their content to another user rather than destroying it.
Is deleting a user reversible?
Removing an account is permanent, which is why this recipe reads first and pauses before every deletion. Downgrading a role instead is fully reversible, so when you only want to cut access, that is the safer move and the agent does it first.