Add support for clearing a session and associated cart contents when switching between accounts using the User Switching plugin. See #21989.

This commit is contained in:
John Blackbourn 2018-11-20 18:58:42 +01:00
parent 179aa0853d
commit b0b36ae4b8
1 changed files with 5 additions and 0 deletions

View File

@ -90,6 +90,11 @@ class WC_Session_Handler extends WC_Session {
add_action( 'shutdown', array( $this, 'save_data' ), 20 );
add_action( 'wp_logout', array( $this, 'destroy_session' ) );
// Support for the User Switching plugin.
add_action( 'switch_to_user', array( $this, 'forget_session' ) );
add_action( 'switch_back_user', array( $this, 'forget_session' ) );
add_action( 'switch_off_user', array( $this, 'forget_session' ) );
if ( ! is_user_logged_in() ) {
add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
}