View Admin as Role: switch back and recovery URL stop working after opening the
-
Hi, I found a reproducible issue with View Admin as Role in ASE 9.3.0 on WordPress 7.1.
Steps: (1) as an administrator, use the View as menu to switch to a role that can edit pages (Editor here), (2) open any page in the block editor, (3) change any editor preference, closing the welcome guide or a sidebar is enough.
Result: the account stays in the Editor role, the Switch back to Administrator item disappears from the admin bar, the recovery URL returns a 200 without restoring anything, and logging out does not restore the role either. The only way back is through WP-CLI or the database.
Cause: the block editor saves its preferences with POST /wp/v2/users/me, which goes through wp_update_user() and fires profile_update. maybe_prevent_switchback_to_administrator() runs on that hook and, since _asenha_viewing_admin_as is not “administrator”, calls clear_view_admin_as_recovery_state(), which removes the original roles, the username from viewing_admin_as_role_are and the recovery token. The roles do not change in that request.
Thanks for the plugin!
You must be logged in to reply to this topic.