User Switching module: Instantly switch between WordPress user accounts
The module User Switching from WPMasterToolKit is designed to allow administrators to quickly and easily switch between WordPress user accounts. This feature is ideal for multi-user sites, where testing different roles and permissions is often necessary. With this module, there's no need to log out and log back in manually: just a few clicks and you're ready to switch accounts or return to your original one.
Which plugin can this module replace?
The "User Switching" module can replace the well-known plugin User Switching without adding unnecessary overhead. By using WPMasterToolKit, you benefit from an integrated, optimized solution, without having to install multiple third-party plugins.
Main features
- Instant switching between accounts : Switch from one user account to another with a single click from the administration interface.
- Quick return to previous user : A "Return to [Username]" option lets you instantly return to your original account.
- Permission retention : Access capabilities are strictly controlled. Only administrators or authorized users can make these changes.
- Integration with the administration bar : Adds a toggle link to the administration bar for quick access.
- WooCommerce compatibility : Manages WooCommerce sessions by clearing session data on switchover to avoid conflicts.
How to use this module
- Activate module : Go to the WPMasterToolKit interface, activate the "User Switching" module and save your settings.
- Access options :
- On the "Users" page in administration, a "Switch To" link appears under each user.
- Click on this link to switch to this user.
- Return to your initial account :
- When a user is switched, a "Switch back to [User name]" option will be visible on the admin bar or on the WordPress login screen.
- Click on this link to return instantly to your original account.
- When a user is switched, a "Switch back to [User name]" option will be visible on the admin bar or on the WordPress login screen.
- Temporary disconnection ("Switch Off") : You can temporarily leave an account without logging out completely, thanks to the "Switch Off" option.
Technical decisions and performance
Optimizing permissions
To ensure that only authorized users can use this functionality, the module applies specific filters on user capabilities, in particular via :
user_has_cap
Controls whether a user has permission to switch to another account.map_meta_cap
Prevent users from switching to their own account or to unauthorized accounts.
These controls reinforce site security and prevent abuse.
Managing cookies and sessions
The module uses cookies to store information about initial users. This ensures a seamless transition between accounts, while enabling quick return to the previous account. For WooCommerce sites, sessions are explicitly managed to avoid conflicts with shopping carts or user sessions.
Integration and lightness
Unlike external solutions, this module is directly integrated into the WPMasterToolKit ecosystem. This means it only loads what is strictly necessary, and respects the plugin's philosophy of "one module activated = one module loaded".
Customized hooks for flexibility
The module offers a number of actions and filters that enable developers to extend or adapt behavior, including :
do_action('wpmastertoolkit/user_switching/switch_to_user', $user_id, $old_user_id, $new_token, $old_token)
Triggered when a user switches to another account.do_action('wpmastertoolkit/user_switching/switch_back_user', $user_id, $old_user_id, $new_token, $old_token)
Triggered on return to previous user.
These hooks allow fine-tuning to the specific needs of the site.
Conclusion
The module User Switching from WPMasterToolKit offers an elegant, integrated solution for quickly switching between user accounts on WordPress. Whether you're a developer testing roles or an administrator managing multiple users, this module simplifies your tasks while guaranteeing security and performance.
With simple installation and intuitive use, it effectively replaces third-party plugins while remaining true to WPMasterToolKit's modular, optimized approach. Try it out now and gain greater efficiency in managing your WordPress users!