Title: How to do it automatically?
Last modified: August 22, 2016

---

# How to do it automatically?

 *  Resolved [rtcunningham](https://wordpress.org/support/users/rtcunningham/)
 * (@rtcunningham)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/how-to-do-it-automatically/)
 * I’m using one admin account for login only and then switching after login. It
   works perfectly, but it’s a few steps every time I log in that I’d love to bypass.
   And then I have to *remember* to switch or it’s another couple of steps to reassign
   the last post.
 * It would be great if this could be done automatically somehow. Any ideas?
 * [https://wordpress.org/plugins/user-switching/](https://wordpress.org/plugins/user-switching/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 9 months ago](https://wordpress.org/support/topic/how-to-do-it-automatically/#post-5204200)
 * You’d have to write some code for it, but you could do something on the `wp_login`
   action to immediately switch user. Maybe something along the lines of this completely
   untested code, where `1` is your admin user ID and `2` is your editor user ID.
 *     ```
       add_action( 'wp_login', function( $user_login, WP_User $user ) {
           if ( 1 == $user->ID ) {
               switch_to_user( 2, true );
           }
       }, 10, 2 );
       ```
   
 *  Thread Starter [rtcunningham](https://wordpress.org/support/users/rtcunningham/)
 * (@rtcunningham)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/how-to-do-it-automatically/#post-5204214)
 * Thanks for trying, but your code doesn’t do anything at all (I just reversed 
   1 and 2). Oh well…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to do it automatically?’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [rtcunningham](https://wordpress.org/support/users/rtcunningham/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/how-to-do-it-automatically/#post-5204214)
 * Status: resolved