User Switching icon
Membership & Users

User Switching hooks reference

  • By John Blackbourn
  • v1.12.2
  • Updated

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.

functions.phpyour child theme
// 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

  • user-switching.php line 1512 · used in 2 places
    /**
     * Allows preventing auth cookies from actually being sent to the client.
     */
    apply_filters( 'user_switching_send_auth_cookies', true );
  • user-switching.php line 478
    /**
     * This filter is documented in wp-login.php
     */
    apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $new_user );
  • user-switching.php line 475
    /**
     * This filter is documented in wp-login.php
     */
    apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $old_user );
  • user-switching.php line 1689
    /**
     * Fires when a user switches back to their originating account.
     */
    do_action( 'switch_back_user', $user_id, $old_user_id, $new_token, $old_token );
  • user-switching.php line 1731
    /**
     * Fires when a user switches off.
     */
    do_action( 'switch_off_user', $old_user_id, $old_token );
  • user-switching.php line 1674
    /**
     * 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.php line 491
    /**
     * 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 );
  • user-switching.php line 545
    /**
     * 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

    action
    user-switching.php line 228
    do_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: