• Resolved audbennett

    (@audbennett)


    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

    (@johnbillion)

    WordPress Core Developer

    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 , or otherwise try to solve the root problem which is multiple users picking up the same order from the shared mailbox.

    Thread Starter audbennett

    (@audbennett)

    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

    (@johnbillion)

    WordPress Core Developer

    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.