johnbillion / user-switching

WordPress plugin that provides instant switching between user accounts.
https://wordpress.org/plugins/user-switching/
GNU General Public License v2.0
187 stars 49 forks source link

Add a 'Switch back to {user}' link to access denied messages within the admin area #118

Closed johnbillion closed 1 month ago

johnbillion commented 2 months ago

Fixes #116

This adds a switch back link to access denied messages within the admin area. This covers:

It doesn't cover the more general "You need a higher level of permission" error messages when attempting to access built-in admin screens to which you don't have access. It is possible to add the link to these screens but some additional guard conditions are needed to ensure the message only shows up when appropriate.

Screenshots

johnbillion commented 2 months ago

@MadtownLems The admin_page_access_denied action sort of worked, although I had to use the shutdown action to actually output the message and add some JavaScript to move the element into place. There's a complete lack of actions or filters in the wp_die() output otherwise.