woocommerce offtopic – Switch to user link shortcode

I am using the User Switching plugin in order to allow sales agents to place an order on behalf of a customer.

I have a page called My Customers which uses toolset to return a list of their customers. I’d like to add a link that allows them to switch to each user on this page.

I have tried adding the following code to functions.php and receive a critical error on the page, code is directly from the developer.

// Add Shortcode
function userswitch_shortcode() {

    if ( method_exists( 'user_switching', 'maybe_switch_url' ) ) {
        $url = user_switching::maybe_switch_url( $target_user );
        if ( $url ) {
            printf(
                '<a href="%1$s">Switch to %2$s</a>',
                esc_url( $url ),
                esc_html( $target_user->display_name )
            );
        }
    }

}
add_shortcode( 'userswitch', 'userswitch_shortcode' );