Skip to content

feat(admin): users-management page with admin/agent role toggles#54

Merged
mpge merged 1 commit into
mainfrom
feat/admin-users-management-ui
May 10, 2026
Merged

feat(admin): users-management page with admin/agent role toggles#54
mpge merged 1 commit into
mainfrom
feat/admin-users-management-ui

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented May 10, 2026

Summary

Port the admin Users management surface from the canonical Laravel reference (escalated-laravel#94) to escalated-wordpress for feature parity.

  • New Escalated -> Users submenu page: lists WordPress users with their Escalated admin / agent state, search by name + email, paginated 20 per page, admins-first ordering.
  • Per-row toggles to grant/revoke the escalated_admin and escalated_agent roles. Same self-demote guard and admin->agent cascade rules as the Laravel reference:
    • Promoting to admin also grants agent.
    • Revoking agent from an admin demotes them fully (avoids the "admin gate on, agent gate off" inconsistency).
    • You cannot revoke your own admin role.
  • Gated by the existing escalated_user_manage capability (held by escalated_admin and the WP administrator role via Activator::add_admin_caps).

WordPress deviation: WP-native roles, not is_admin / is_agent columns

The Laravel reference flips is_admin / is_agent boolean columns on a host User row. This plugin does not -- and cannot, without forcing every WordPress site to alter wp_users. WordPress has a first-class role / capability system that every other Escalated admin gate in this plugin already uses (see Activator::create_roles and Activator::add_admin_caps), so the port toggles WP roles instead:

Laravel column WordPress equivalent
is_admin = true user has escalated_admin role (or WP administrator)
is_agent = true user has escalated_agent role (or admin, since admins are agents)

The cascade and self-demote logic is identical to the Laravel reference; only the underlying write target differs. Admin_Users::user_is_admin / user_is_agent project the role state into the same {is_admin, is_agent} row shape the Vue reference page consumed.

Frontend deviation: no Vue SPA

escalated-wordpress does not consume the @escalated-dev/escalated Vue SPA (there is no top-level package.json); the plugin renders its admin screens with native WordPress templates under wp-admin. The new page therefore lives at templates/admin/users.php using wp-list-table markup rather than re-mounting Escalated/Admin/Users/Index.vue. The ^0.8.0 bump in the brief does not apply here.

Changes

  • includes/Admin/class-admin-users.php -- new admin controller (render + handle_actions + pure update_role() for testability).
  • templates/admin/users.php -- list + search + per-row role toggle forms.
  • includes/Admin/class-admin-menu.php -- register the new submenu under escalated_user_manage.
  • tests/Test_Admin_Users.php -- 7 PHPUnit cases mirroring tests/Feature/Admin/UserControllerTest.php in the Laravel reference.
  • CHANGELOG.md -- [Unreleased] entry.

Test plan

  • CI: Tests job (PHP 8.1, 8.2) green.
  • CI: Lint job (Pint) green.
  • Manual smoke (post-merge): visit wp-admin -> Escalated -> Users, search, toggle admin / agent on a non-self user, attempt self-demote (should fail), revoke agent on another admin (should clear both roles).

Reference: escalated-laravel#94

Port the Laravel reference Users management surface
(escalated-laravel #94) to a native WordPress admin screen.

New Users submenu lists WP users with their Escalated admin/agent
state, supports name/email search, and is paginated 20 per page.
Admins can grant or revoke the escalated_admin / escalated_agent
roles per user. The same self-demote guard and admin->agent cascade
rules as the Laravel reference apply.

WordPress deviation: instead of toggling is_admin / is_agent columns
on a host User row, the toggle flips native WP roles
(escalated_admin, escalated_agent) on the WP_User — that is the
permission surface every other Escalated admin gate already uses
(see Activator::create_roles / add_admin_caps).

Gated by the existing escalated_user_manage capability.

Tests: 7 PHPUnit cases mirroring tests/Feature/Admin/UserControllerTest
in the Laravel reference (list/search renders, capability gate,
admin promotion cascade, agent-only promotion, self-demote guard,
agent-revoke-on-admin cascade, search filter).
@mpge mpge merged commit 456e1d1 into main May 10, 2026
3 checks passed
@mpge mpge deleted the feat/admin-users-management-ui branch May 10, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant