• Resolved Lucas

    (@lucasp1)


    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bowo

    (@qriouslad)

    @lucasp1 Thank you for the detailed report and diagnosis. A fix will be included in the next release, scheduled for next Monday. Please test when you see it.

    Thread Starter Lucas

    (@lucasp1)

    Hi @qriouslad , thanks a lot for the quick fix in 9.3.1, and for the credit. I tested it on the same site without my workaround: the block editor preferences no longer lock the account out, and a real role change still clears the recovery state, so I removed the workaround.

    I noticed another side effect of View Admin as Role, on the dashboard this time. Since the account itself switches role, any widget arrangement made while viewing as another role is saved on the administrator’s own account, and WordPress only saves the widgets present on the screen. Steps: (1) as an administrator, arrange the dashboard widgets; (2) view as Editor, who does not see the Site Health Status widget; (3) drag a single widget; (4) switch back to administrator. The widgets the other role could not see are gone from the saved order (meta-box-order_dashboard), so WordPress stacks them at the bottom of the first column and the administrator’s layout is lost.

    I’m not sure whether you consider this in scope for View Admin as Role, but I wanted to let you know. Thanks again!

    Plugin Author Bowo

    (@qriouslad)

    @lucasp1 thanks for the additional report. That’s something within the scope of View Admin as Role module as well. Will try to implement a fix for the next release. Please test when you see it.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.