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

Ask for confirmation when switching into an account which somebody else is already switched into #94

Open johnbillion opened 2 years ago

johnbillion commented 2 years ago

As requested by audbennett on https://wordpress.org/support/topic/show-in-use/

Customers email orders to us in a shared mailbox so that anyone in the company can read the email and enter the order. However, what’s been happening a lot is that two people will get it at the same time (because outlook hasn’t marked it as “read” yet) and both of us will start entering it using the “Switch To” feature. Is it possible to set an alert on the backend “Users screen” that will alert you when someone else is already logged in as that user?

I quite like the idea of alerting a user when they attempt to switch to a user account into which somebody else is currently switched. I can see this being beneficial on sites that make heavy use of switching.

Rather than showing a message on the Users screen it should be shown at the point where the user clicks "Switch to", otherwise you'd still get a condition where two users load the Users screen in quick succession and neither are shown that another user has switched into any given account.

When a user switches, if another user is currently switched into that account then an "Are you sure?" message should be shown (probably via wp_die()) with the option to proceed or go back. The WordPress user session API can be used to check if there's another active session for the target user with a switched_from_id field present.

johnbillion commented 2 years ago

"John Blackbourn is currently switched to Joe Public. They switched 2 minutes ago. Do you want to continue switching to Joe Public?"