feat(admin): users-management page with admin/agent role toggles#54
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port the admin Users management surface from the canonical Laravel reference (escalated-laravel#94) to
escalated-wordpressfor feature parity.escalated_adminandescalated_agentroles. Same self-demote guard and admin->agent cascade rules as the Laravel reference:escalated_user_managecapability (held byescalated_adminand the WPadministratorrole viaActivator::add_admin_caps).WordPress deviation: WP-native roles, not is_admin / is_agent columns
The Laravel reference flips
is_admin/is_agentboolean columns on a host User row. This plugin does not -- and cannot, without forcing every WordPress site to alterwp_users. WordPress has a first-class role / capability system that every other Escalated admin gate in this plugin already uses (seeActivator::create_rolesandActivator::add_admin_caps), so the port toggles WP roles instead:is_admin = trueescalated_adminrole (or WPadministrator)is_agent = trueescalated_agentrole (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_agentproject the role state into the same{is_admin, is_agent}row shape the Vue reference page consumed.Frontend deviation: no Vue SPA
escalated-wordpressdoes not consume the@escalated-dev/escalatedVue SPA (there is no top-levelpackage.json); the plugin renders its admin screens with native WordPress templates underwp-admin. The new page therefore lives attemplates/admin/users.phpusingwp-list-tablemarkup rather than re-mountingEscalated/Admin/Users/Index.vue. The^0.8.0bump in the brief does not apply here.Changes
includes/Admin/class-admin-users.php-- new admin controller (render + handle_actions + pureupdate_role()for testability).templates/admin/users.php-- list + search + per-row role toggle forms.includes/Admin/class-admin-menu.php-- register the new submenu underescalated_user_manage.tests/Test_Admin_Users.php-- 7 PHPUnit cases mirroringtests/Feature/Admin/UserControllerTest.phpin the Laravel reference.CHANGELOG.md--[Unreleased]entry.Test plan
Testsjob (PHP 8.1, 8.2) green.Lintjob (Pint) green.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