User Switching 1.12.2 has 7 actions and 7 filters, read directly from its source code on Nov 17, 2026. The list updates automatically when a new version is released.
How to use these hooks
Actions let you run your own code at a specific moment. Filters let you change a value before the plugin uses it. Put your code in a child theme's functions.php or a code-snippets plugin, never in the plugin's own files, because updates overwrite them.
// Run your own code when User Switching fires an action
add_action( 'clear_olduser_cookie', function() {
// Your code runs here.
}, 10, 1 );
// Change a value User Switching is about to use
add_filter( 'user_switching_send_auth_cookies', function( $value ) {
// Change $value here.
return $value;
}, 10, 1 );Parts of a name in {braces} are filled in at runtime (for example a post type or field ID). Choose Example on any hook for a ready-to-edit snippet.
All hooks
-
/** * Allows preventing auth cookies from actually being sent to the client. */ apply_filters( 'user_switching_send_auth_cookies', true ); -
auth_cookie_expiration
filter/** * This filter is documented in wp-includes/pluggable.php */ apply_filters( 'auth_cookie_expiration', 172800, get_current_user_id(), false ); -
clear_olduser_cookie
action/** * Fires just before the User Switching cookies are cleared. */ do_action( 'clear_olduser_cookie' ); -
login_redirect
filter/** * This filter is documented in wp-login.php */ apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $new_user ); -
logout_redirect
filter/** * This filter is documented in wp-login.php */ apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $old_user ); -
set_olduser_cookie
action/** * Fires immediately before the User Switching old user cookie is set. */ do_action( 'set_olduser_cookie', $olduser_cookie, $expiration, $old_user_id, $scheme, $token ); -
set_user_switching_cookie
action/** * Fires immediately before the User Switching authentication cookie is set. */ do_action( 'set_user_switching_cookie', $auth_cookie, $expiration, $old_user_id, $scheme, $token ); -
switch_back_user
action/** * Fires when a user switches back to their originating account. */ do_action( 'switch_back_user', $user_id, $old_user_id, $new_token, $old_token ); -
switch_off_user
action/** * Fires when a user switches off. */ do_action( 'switch_off_user', $old_user_id, $old_token ); -
switch_to_user
action/** * Fires when a user switches to another user account. */ do_action( 'switch_to_user', $user_id, $old_user_id, $new_token, $old_token ); -
user_switching_redirect_to
filter/** * Filters the redirect location after a user switches to another account or * switches off. */ apply_filters( 'user_switching_redirect_to', $redirect_to, $redirect_type, $new_user, $old_user ); -
/** * Filters the contents of the message that's displayed to switched users in * the admin area. */ apply_filters( 'user_switching_switched_message', $message, $user, $old_user, $switch_back_url, $just_switched ); -
qm/cease
actiondo_action( 'qm/cease' );
Generated from User Switching's GPL-licensed source code. Hooks inside bundled third-party libraries are not listed.
Can't find the right hook?
We can build the customisation for you. Describe what you need: