Title: Block User
Last modified: November 3, 2021

---

# Block User

 *  Resolved [audbennett](https://wordpress.org/support/users/audbennett/)
 * (@audbennett)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/block-user-5/)
 * Hello – Is it possible to only allow one user to switch into one person at a 
   time? For example, we use User Switching with WooCommerce to enter customer orders
   as that customer. However, since customers send their orders to a shared mailbox,
   two people could pick up the order at the same time, switch to that user and 
   start entering an order for them. This causes all quantities to double. It would
   be extremely helpful if once the first person switches into that user, it blocks
   anyone else from switching into them until the first person has “switched back”.
   I tried entering the snippet for “Can I determine whether the current user switched
   into their account?” but it didn’t work.
    Thanks.

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

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [4 years, 5 months ago](https://wordpress.org/support/topic/block-user-5/#post-15032572)
 * This should be possible but you’d need to introduce a means of centrally tracking
   which users are currently switched into which accounts, which is not something
   that User Switching provides.
 * I recommend posting a job request on [https://codeable.io](https://codeable.io),
   or otherwise try to solve the root problem which is multiple users picking up
   the same order from the shared mailbox.
 *  Thread Starter [audbennett](https://wordpress.org/support/users/audbennett/)
 * (@audbennett)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/block-user-5/#post-15032810)
 * OK, thank you!. Can you tell me what the following code is supposed to do? Where
   is it supposed to show that the user has switched into their account?
 *     ```
       if ( function_exists( 'current_user_switched' ) ) {
           $switched_user = current_user_switched();
           if ( $switched_user ) {
               // User is logged in and has switched into their account.
               // $switched_user is the WP_User object for their originating user.
           }
       }
       ```
   
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [4 years, 5 months ago](https://wordpress.org/support/topic/block-user-5/#post-15032816)
 * You need to add some output to the innermost condition (where the commented out
   lines are) to display a message of your choosing. It’s just example code for 
   a developer who wants to use this logic.

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

The topic ‘Block User’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/block-user-5/#post-15032816)
 * Status: resolved